Obtaining an Authorization Code
Function
When a user accesses an integrated application, the application sends an authorization request (in redirection mode) to OneAccess. The user enters their username and password to complete the authentication. OneAccess redirects the user to the application with an authorization code transferred in the code parameter.
URI
GET /api/v1/oauth2/authorize
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
client_id |
Yes |
String |
Application ID, which is a client ID allocated to an application after registration. |
redirect_uri |
No |
String |
Callback address, which is used by the application to receive the OneAccess authorization code. The address can be the callback address or the domain name entered during application registration. |
response_type |
Yes |
String |
Grant type. The value is fixed at code. |
scope |
No |
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
Parameter |
Type |
Description |
---|---|---|
Location |
String |
Redirection address used after successful authentication. Example: https://example.com?code=z2D...&state=test |
Example Requests
Obtain the OIDC authorization code. The value of the grant type is fixed at code. Configure clientId generated in the application registration. Callback address after the grant is successful: https://example.com. The value of the scope of the granted access is fixed at openid.
GET https://{domain_name}/api/v1/oauth2/authorize?response_type=code&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 authorization code. Example: https://example.com?code=z2D...&state=test |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot