OAuth簽發存取權杖

OAuth

簽發存取權杖

client_credentials、authorization_code、refresh_token 可換取 3600 秒有效的權杖。

POSThttps://api.sofia-post.com/api/v1/oauth/token

請求本文

application/x-www-form-urlencoded, application/json

  • grant_typestring必填

    要交換的授權類型:client_credentials、authorization_code 或 refresh_token

    允許的值: client_credentialsauthorization_coderefresh_token

  • client_idstring必填

    用戶端應用的識別碼

  • client_secretstring

    機密用戶端的金鑰(client_secret_post),或放在 Authorization: Basic 標頭中(client_secret_basic),不可同時使用;公開用戶端無需提供

  • scopestring

    申請的 scope,以空格分隔;省略則為該授權的全部 scope

  • workspace_idstring

    權杖所操作的 Workspace:在 client_credentials 下應用有多個時必填,只有一個時可選

  • codestring

    authorization_code:在重新導向位址收到的授權碼

  • code_verifierstring

    authorization_code:PKCE 驗證碼(RFC 7636)

  • redirect_uristring

    authorization_code:與授權時相同的重新導向位址

  • refresh_tokenstring

    refresh_token:更新權杖,僅可使用一次

回應

200application/json

存取權杖;只有授予了 offline_access 才會包含 refresh_token。

  • access_tokenstring必填

    不透明的存取權杖

  • token_typestring必填

    始終為 Bearer

    允許的值: Bearer

  • expires_innumber必填

    有效期,單位為秒

  • scopestring必填

    已授予的 scope,以空格分隔

  • refresh_tokenstring

    僅限 authorization_code 和 refresh_token,且已授予 offline_access:僅可使用一次,每次交換都會輪替

400

invalid_request、invalid_grant、unsupported_grant_type、invalid_scope 或 unauthorized_client。

401

invalid_client:未知用戶端、金鑰錯誤或缺失,或應用已被撤銷。