layout: docs-default
令牌 Endpoint
程序可以调用令牌endpoint来请求和刷新令牌 (resource owner password credential flow, authorization code flow, client credentials flow 和自定义授权类型).
支持参数
请看 规格.
-
grant_type(必填)-
authorization_code,client_credentials,password,refresh_token或者自定义
-
-
scope(除了refresh_token and code,都必填) -
redirect_uri(code grant type必填) -
code( code grant必填) -
code_verifier(当使用proof keys时必填 - v2.5新增) -
username( password grant type必填) -
password(password grant_type必填) -
acr_values( password grant type用来传送附加信息给用户服务)- 里面的值有指定格式:
-
idp:name_of_idp跳过登陆/主页界面并直接把用户转到选择的第三方认证服务器(基于客户端配置) -
tenant:name_of_tenant用于把承租人名字转给用户服务
-
- 里面的值有指定格式:
-
refresh_token(refresh token grant必填) -
client_id(在post body里或者在basic authentication header) -
client_secret(在post body里或者在basic authentication header)
认证
发到令牌endpoint的请求,必须已认证--或者通过基础认证里的客户端ID和密钥或者把客户端ID和密钥放在Post的body里。
如果放在基础认证的header里面,要求如下:
client_id:client_secret- Base64 转码
var clientId = "...";
var clientSecret = "...";
var encoding = Encoding.UTF8;
var credentials = string.Format("{0}:{1}", clientId, clientSecret);
var headerValue = Convert.ToBase64String(encoding.GetBytes(credentials));
例子
(方便阅读,已经去除了Form转码和增加换行)
POST /connect/token
Authorization: Basic abcxyz
grant_type=authorization_code&
code=hdh922&
redirect_uri=https://myapp.com/callback