Obtain Standard Authorization Code
When a user accesses a third-party application, the third-party application initiates an authorization login request to Zhuyun IDaaS. After the user successfully authenticates by entering their username and password, Zhuyun IDaaS will redirect back to the third-party application, including the authorization code parameter.
# Request Description
GET https://{your_domain}/api/v1/oauth2/authorize
# Request Headers
None
# Request Example
GET https://{your_domain}/api/v1/oauth2/authorize?response_type=code&client_id={client_id}&redirect_uri=http://oauthdemo.bccastle.com/demo/index.jsp&state=123456
# Request Parameters
| Parameter Name | Chinese Name | Required | Example Value | Description |
|---|---|---|---|---|
| response_type | Authorization Type | Required | code | This value must be 'code'. |
| client_id | Application Identifier | Required | RqB2676qA | The client_id assigned to the third-party application after registration. |
| redirect_uri | Callback URL | Optional | http://oauthdemo.bccastle.com /demo/index.jsp | The callback URL after authorization. Must match the trusted domain registered for the application. Note: The URL needs to be URLEncoded. |
| state | Client State Code | Optional | 15924362 | A state value from the client. Used to prevent CSRF attacks. Will be returned unchanged in the callback after successful authorization. Please verify the binding between the user and this state. |
| scope | Scope of Application | Optional | get_user_info | This value must be 'get_user_info'. |
# Response Examples
Successful Response Example
HTTP Status: 302 REDIRECT
http://oauthdemo.bccastle.com/demo/index.jsp?code=a2WskPcoue0ymFh0B8Q&state=123456
Missing client_id parameter
HTTP Status: 400 BAD REQUEST
{
"error": "invalid_request",
"error_description": "Missing client_id"
}
Incorrect client_id parameter
HTTP Status: 400 BAD REQUEST
{
"error": "invalid_request",
"error_description": "client_id parameter is error"
}
Incorrect response_type parameter name or value
HTTP Status: 400 BAD REQUEST
{
"error": "unsupported_response_type",
"error_description": "Unsupported response types: [xxx]"
}
Incorrect redirect_uri parameter
HTTP Status: 400 BAD REQUEST {
"error": "invalid_request",
"error_description": "Invalid redirect: https://www.baidu.com does not match one of the registered values."
}
Incorrect scope parameter
HTTP Status: 302
{redirect_uri}?error=invalid_scope&error_description=Invalid scope: xxx&state=123456
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Response Parameters
If the user successfully logs in and authorizes, they will be redirected to the specified callback address, with the Authorization Code and the original state value appended to the redirect_uri.
| Parameter Name | Chinese Name | Required | Example Value | Description |
|---|---|---|---|---|
| code | Authorization Code | Required | stRWlW | The authorization code returned by the authorization server to the application after the user logs in and authorizes. Note: This code is valid for 5 minutes and can only be used once within its validity period. |
| state | Client State Code | Optional | 15924362 | The state value from the client side. Used by third-party applications to prevent CSRF attacks. It will be returned as-is in the callback upon successful authorization. |
I am ready. Please provide the Markdown content you need translated.
