Updated on 2024-12-30 GMT+08:00

Performing Implicit Grant

Function

When a user accesses an integrated application, the application obtains an access token and ID token through implicit grant, and sends a grant request (in redirection mode) to OneAccess. If the grant is successful after the user enters their username and password, OneAccess redirects the user to the application with the access token and ID token.

URI

GET /api/v1/oauth2/authorize

Table 1 Query Parameters

Parameter

Mandatory

Type

Description

client_id

Yes

String

Application ID, which is a client ID allocated to an application after registration.

redirect_uri

Yes

String

Callback address, which is used by the application to receive the address of OneAccess token (ID token or access token). The address can be the callback address or the domain name entered during application registration.

response_type

Yes

String

Grant type. Options: id_token or id_token token.

  • id_token: An ID token is returned.

  • id_token token: An access token and ID token are returned.

scope

Yes

String

Scope of the granted access. The value is fixed at openid.

state

No

String

Application status, which is used to prevent CSRF attacks. After successful authorization, the status is returned during callback to verify the mapping between the authentication and callback requests. The status can contain letters and digits.

Request Parameters

None

Response Parameters

Status code: 302

Table 2 Response header parameters

Parameter

Type

Description

location

String

Redirection address used after successful authentication. - If the grant type of list text here is id_token, https://example.com#id_token=eyJraWQiOi.JlNWFlNTg1Mzky.NjA0Njg... is returned. - If the grant type of list text here is id_token token, https://example.com#access_token=f9dd6b8a-4b4f-4380-bf3a-39f8bfbef...&token_type=Bearer&expires_in=7199&id_token=eyJraWQiOi.JlNWFlNTg1Mzky.NjA0Njg... is returned.

Example Requests

  • Implicit grant is performed based on the grant type value id_token token. In this case, the response carries access_token and id_token.

    GET https://{domain_name}/api/v1/oauth2/authorize?response_type=id_token token&client_id=cU0L3GsEq1vuOJ5iQrRSu5AyPnKL8...&redirect_uri=https://example.com&scope=openid&state=test
  • Implicit grant is performed based on the grant type value id_token. In this case, the response carries id_token.

    GET https://{domain_name}/api/v1/oauth2/authorize?response_type=id_token&client_id=cU0L3GsEq1vuOJ5iQrRSu5AyPnKL8...&redirect_uri=https://example.com&scope=openid&state=test

Example Responses

None

Status Codes

Status Code

Description

302

The login fails, and the user is redirected to the login page. The login is successful, and the user is redirected to redirect_uri with an access token and ID token.

Error Codes

See Error Codes.