oauth2.0-各种授权类型示例代码
authorization_code
请求临时令牌
请求
1  | https://oauth2server.com/oauth/authorize?client_id=a17c21ed&response_type=code&state=5ca75bd30&redirect_uri=https://oauth2client.com/auth  | 
响应
1  | https://oauth2client.com/cb?code=Yzk5ZDczMzRlNDEwY  | 
异常
1  | HTTP/1.1 2 Found  | 
交换获取令牌
请求
1  | POST /oauth/token HTTP/1.1  | 
响应
1  | HTTP/1.1 200 OK  | 
异常
1  | HTTP/1.1 400 Bad Request  | 
Implicit Grant
browser-base
请求
1  | https://oauth2server.com/oauth/authorize?response_type=token&client_id=mRkZGFjM&state=TY2OTZhZGFk  | 
响应
1  | https://oauth2client.com/cb#token=Yzk5ZDczMzRlNDEwY&state=TY2OTZhZGFk  | 
mobile and native app
请求
1  | https://www.arcgis.com/sharing/oauth2/authorize?client_id=eKNjzFFjH9A1ysYd&response_type=token&redirect_uri=exampleapp://auth  | 
响应
1  | oauthdemo://auth#access_token=lS0KgilpRsT07qT_iMOg9bBSaWqODC1g061nSLsa8gV2GYtyynB6A-abCsWrDTvN9p7rI0kWa4u-ORXuFUQ7QGxiiniwpCSIV1AqzoLRHF1hYcI4joeDPOzZa9PZigiudtefciZy5&expires_in=7199&username=aaronpk  | 
Paasword Grant
请求
1  | POST /oauth/token HTTP/1.1  | 
Client Credentials
概述
1  | 访问自身资源,不代表用户行为  | 
请求
1  | POST /oauth/token HTTP/1.1  | 
refresh token
注意
1  | 如果包含scope,需与上一次的scope相同  | 
请求
1  | POST /oauth/token HTTP/1.1  | 
oauth2.0-各种授权类型示例代码

