Password Mode Authentication
Users input their username and password on the client to log in. The client application backend calls the unified authentication platform's Get Access Token interface.
# Request Description
POST https://{your_domain}/api/v1/oauth2/token
# Request Headers
| Parameter Name | Chinese Name | Required | Example Value | Description |
|---|---|---|---|---|
| Authorization | Authentication Information | Required | Basic UnFCMOWk9xWA== | Use client_id and client_secret for base64 authentication, format: base64(client_id:client_secret) |
| Content-Type | Data Type | Required | application/x-www-form-urlencoded | Submit parameters using form format |
# Request Example
POST https://{your_domain}/api/v1/oauth2/token
Authorization: Basic UnFCMkhKdGt6bFU...aT0NObkk4NlNOWk9xWA==
Content-Type: application/x-www-form-urlencoded
username=test&password=123456&grant_type=password
# Request Parameters
| Parameter Name | Chinese Name | Required | Example Value | Description |
|---|---|---|---|---|
| grant_type | Grant Type | Yes | password | password |
| username | Login Name | Yes | test | Login Name / Phone Number / Email |
| password | Password | Yes | 123456 |
# Response Example
Successful Response Example
{
"access_token": "8ab9812c-1076-47f0-9e4a-6d48280ec524",
"token_type": "bearer",
"refresh_token": "92fe3c7a-f8ad-4dc3-b0c4-c0281c1fa560",
"expires_in": 3804,
"scope": "get_user_info"
}
Username is empty
HTTP Status: 400 Bad Request
{
"error": "invalid_request",
"error_description": "An authorization username must be supplied."
}
Incorrect username or password
HTTP Status: 400 Bad Request
{
"error": "invalid_grant",
"error_description": "Bad credentials"
}
User is locked
HTTP Status: 400 Bad Request
{
"error": "invalid_grant",
"error_description": "User is locked"
}
User is disabled
HTTP Status: 400 Bad Request
{
"error": "invalid_grant",
"error_description": "User is disabled"
}
User password has expired
HTTP Status: 400 Bad Request
{
"error": "invalid_grant",
"error_description": "Password has expired"
}
Application credentials error
HTTP Status: 401 UNAUTHORIZED
{
"error": "invalid_client",
"error_description": "Bad client credentials"
}
1
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Response Parameters
If the user successfully logs in and grants authorization, the system's authorization token (access token) will be returned.
| Parameter Name | Chinese Name | Example Value | Description |
|---|---|---|---|
| access_token | Authorization Token | 8ab9812c-1076-47f0-9e4a-6d48280ec524 | The authorization token returned by the authorization server to the third-party application. All subsequent API accesses require this parameter. |
| expires_in | Validity Period of Authorization Token | 1500 | The validity period of the access credential returned by the authorization server to the application. Note: The validity period is in seconds. |
| refresh_token | Refresh Token | 92fe3c7a-f8ad-4dc3-b0c4-c0281c1fa560 | |
| token_type | Token Type | bearer | |
| scope | Authorization Scope | get_user_info |
