Refresh Token

Refresh Token

环境与入口

生产issuer为 https://accounts.appforges.com,staging为 https://accounts-staging.appforges.com。浏览器用户授权入口是对应issuer的 /oauth2/authorize,token交换是 /oauth2/token。用户业务API为对应环境的api域名;不要把REST /v1/oauth/authorize 当成浏览器登录入口。

在应用Credentials创建OAuth client,配置Public/Confidential模式、redirect URIs与allowed scopes。复制实际client_id,不把app_id当成client_id。Public client使用PKCE S256且不持有client_secret;Confidential secret只放安全后端。

刷新用户授权

仅在token响应实际包含refresh_token且client允许相应grant时刷新。对同issuer /oauth2/token 提交form-encoded grant_type=refresh_token、refresh_token与client_id,并按client登记的认证方式处理。

响应返回新的refresh_token时原子替换安全存储;同一授权的并发刷新应串行化,避免旧token覆盖新值。使用expires_in设置过期时间,刷新失败时重新走用户授权,不能无界重试。不要把refresh_token放浏览器URL或日志。

见用户授权与错误重试。