使用grant_type=password方式来获取access_token
请求URI: /oauth/token
POST
参数名 | 参数值 | 必须? | 备注 |
---|---|---|---|
client_id | {client_id} | 是 | |
client_secret | {client_secret} | 是 | |
grant_type | password | 是 | 固定值 |
scope | {scope} | 是 | read or write |
username | {username} | 是 | 用户名 |
password | {password} | 是 | 用户密码 |
http://localhost:8080/spring-oauth-server/oauth/token?client_id=6361b08fdea6400f93b2eccda8936b32&client_secret=i4KXewMI0u6i8CFEZo10mB2rGzQRXrIv&grant_type=password&scope=read&username=mobile&password=mobile
正常 [200]
{"access_token":"1f60abaf-6c3f-45a8-a574-bbbe6f76083f","token_type":"bearer","expires_in":41769,"scope":"read"}
异常 [401]
<oauth><error_description>Bad client credentials</error_description><error>invalid_client</error></oauth>
使用grant_type=authorization_code 方式来获取access_token, 需要先获取code
请求URI: /oauth/token
POST
参数名 | 参数值 | 必须? | 备注 |
---|---|---|---|
client_id | {client_id} | 是 | |
client_secret | {client_secret} | 是 | |
grant_type | authorization_code | 是 | 固定值 |
code | {code} | 是 | |
redirect_uri | {redirect_uri} | 是 |
http://localhost:8080/spring-oauth-server/oauth/token?client_id=unity-client&client_secret=unity&grant_type=authorization_code&code=[code]&redirect_uri=[redirect_uri]
正常 [200]
{"access_token":"2c612eb7-a22b-45f0-8b2e-cd6f9e366772","token_type":"bearer","refresh_token":"6c984bdc-01c7-486f-93bf-5637990d8a37","expires_in":43199,"scope":"read
write"}
异常 [401]
{"error":"invalid_grant","error_description":"Invalid authorization code: vzmIh1"}
© 2013 - 2016 sz@monkeyk.com from spring-oauth-server