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或日誌。