GET
名称 | 类型 | 必填 | 描述 |
client_id | string | 是 | 自建应用的 Client ID示例值:i-3f7f5**************************d0 |
response_type | string | 是 | 固定值: code示例值:code |
redirect_uri | string | 是 | 应用接收授权码的回调地址。该回调地址必须在“企业管理后台 > 自建应用 > 认证配置 >登录回调地址”中配置。 示例值: https://example.com/oauth/callback |
state | string | 否 | 认证完成后,OneID 会原封不动的把 state 的值返回给 redirect_uri。 示例值:xyz |
scope | string | 否 | 推荐使用,应用需要 OneID 用户信息的范围。多个 scope 值以空格分割。 可选值参考:“企业管理后台 > 自建应用 > Scope 配置”,注意: • scope 中包含 offline_access,则返回 refresh_token;• scope 中包含 openid,则返回 id_token;示例值:openid profile email mobile offline_access oneid.departments.read |
参数名称 | 类型 | 描述 |
code | string | 授权码,有效期 300 秒,只能用一次 |
state | string | 原样返回请求中传入的 state |
https://oauth2.account.tencentid.com/authz/oidc/v2/13580************30/authorize?client_id=i-3f7f5**************************d0&response_type=code&redirect_uri=https://example.com/oauth/callback&scope=openid profile email mobile offline_access&state=xyz


https://example.com/oauth/callback?code=cf773c*************************94&state=xxxx
https://example.com/oauth/callback?error=xxxx&error_description=xxxx
错误码 | 描述 |
invalid_request | redirect_uri 未登记或参数不合法 |
invalid_scope | scope 未启用;或应用未启用 refresh_token 授权类型却请求了 offline_access |
invalid_client | client_id 不存在或已禁用 |
POST
名称 | 类型 | 必填 | 描述 |
Content-Type | string | 是 | 固定值: application/x-www-form-urlencoded |
名称 | 类型 | 必填 | 描述 |
client_id | string | 是 | 自建应用的 Client ID示例值:i-3f7f5*************************d0 |
client_secret | string | 是 | 应用的 Client Secret。缺省报 missing client_secret。 示例值:HydF*************************7K@{lnL |
grant_type | string | 是 | 固定值: authorization_code示例值:authorization_code |
code | string | 是 | 登录用户授权码。请注意,code 有效期为5分钟,且只能使用一次。 示例值:cf773c*************************94 |
redirect_uri | string | 是 | 生成“登录用户授权码”时传入的 redirect_uri。请注意,指定到 path,无需包含 query。示例值: https://example.com/oauth/callback |
名称 | 类型 | 描述 |
access_token | string | 访问凭证。 |
token_type | string | 凭证类型。目前为不记名凭证,即 Bearer。 |
expires_in | int | 凭证的有效期,单位:秒。 |
refresh_token | string | 用于刷新 access_token。当生成“登录用户授权码”时 scope 包含 offline_access 时才会颁发。 |
id_token | string | JWT 格式的用户信息。当生成“登录用户授权码”时 scope 包含 openid 时才会颁发。 除了用户信息还包括 OneID 当前登录态的基本信息, 例如: • sid:OneID 登录会话唯一标识• auth_time:OneID 登录会话建立的时间戳• sexp:OneID 登录会话过期的时间戳• amr:OneID 登录会话使用的认证方式 |
POST https://oauth2.account.tencentid.com/authz/oidc/v2/13580************30/tokenContent-Type: application/x-www-form-urlencodedclient_id=i-3f7f5*************************d0&client_secret={secret}&grant_type=authorization_code&code=cf773*************************94&redirect_uri=https://example.com/oauth/callback
{"access_token": "eyJhb*************************","token_type": "Bearer","expires_in": 1800,"refresh_token": "ccc30**********************07131","id_token": "eyJhb*************************"}
错误码 | 描述 |
invalid_request | 缺 client_secret / code / redirect_uri |
invalid_client | client_secret 不匹配 |
invalid_grant | code 失效或已使用 |
POST
名称 | 类型 | 必填 | 描述 |
Content-Type | string | 是 | 固定值: application/x-www-form-urlencoded |
名称 | 类型 | 必填 | 描述 |
client_id | string | 是 | 自建应用的 Client ID示例值:i-3f7f5*************************d0 |
client_secret | string | 是 | 自建应用的 Client Secret示例值:HydF*************************7K@{lnL |
grant_type | string | 是 | 固定值: refresh_token示例值:refresh_token |
refresh_token | string | 是 | 刷新令牌,用于刷新 access_token 以及 refresh_token。示例值:ccc30**********c2b78e6d6f4be07131 |
名称 | 类型 | 描述 |
access_token | string | 访问凭证 |
refresh_token | string | 新生成的 refresh_token,建议使用者保存并覆盖之前的 refresh_token。 注:之前颁发的 refresh_token 并不会被注销。 |
token_type | string | 凭证类型。目前为不记名凭证,即 Bearer |
expires_in | int | 凭证的有效期,单位:秒。 |
id_token | string | JWT 格式的用户信息。当生成“登录用户授权码”时 scope 包含 openid 时才会颁发。 除了用户信息还包括 OneID 当前登录态的基本信息, 例如: • sid:OneID 登录会话唯一标识• auth_time:OneID 登录会话建立的时间戳• sexp:OneID 登录会话过期的时间戳• amr:OneID 登录会话使用的认证方式 |
POST https://oauth2.account.tencentid.com/authz/oidc/v2/13580************30/tokenContent-Type: application/x-www-form-urlencodedclient_id=i-3f7f5*************************d0&client_secret=HydF*************************7K@{lnL&grant_type=refresh_token&refresh_token=ccc30**********c2b78e6d6f4be07131
{"access_token": "eyJhb***********************hu","token_type": "Bearer","expires_in": 1800,"refresh_token": "b6122*************************0e","id_token": "eyJhb***********************gr"}
错误码 | 描述 |
invalid_request | 缺 refresh_token;或 refresh_token 已失效 |
invalid_client | client_secret 不匹配 |
invalid_grant | refresh_token 无效 |
文档反馈