Documentation
¶
Index ¶
- Variables
- func GenerateClientSecret(signingKey, teamID, clientID, keyID string) (string, error)
- func IDTokenClaims(idToken string) (jwt.MapClaims, error)
- func RevokeAccessToken(ctx context.Context, reqBody RevokeAccessTokenRequest) error
- func RevokeRefreshToken(ctx context.Context, req RevokeRefreshTokenRequest) error
- type AppValidationTokenRequest
- type RevokeAccessTokenRequest
- type RevokeRefreshTokenRequest
- type ValidationRefreshRequest
- type ValidationTokenResponse
- func VerifyAppToken(ctx context.Context, reqBody AppValidationTokenRequest) (*ValidationTokenResponse, error)
- func VerifyRefreshToken(ctx context.Context, req ValidationRefreshRequest) (*ValidationTokenResponse, error)
- func VerifyWebToken(ctx context.Context, reqBody WebValidationTokenRequest) (*ValidationTokenResponse, error)
- type WebValidationTokenRequest
Constants ¶
This section is empty.
Variables ¶
var ( // ValidationURL is the endpoint for verifying tokens ValidationURL = "https://appleid.apple.com/auth/token" // RevokeURL is the endpoint for revoking tokens RevokeURL = "https://appleid.apple.com/auth/revoke" )
Functions ¶
func GenerateClientSecret ¶
GenerateClientSecret 生成用于向验证服务器发出请求的客户端机密。 该秘密将在180天后过期 signingKey-通过进入开发者部分的密钥部分获得的来自苹果的私钥 teamID-您的10个字符的团队ID clientID-您的服务ID,例如com.test.Services
func RevokeAccessToken ¶
func RevokeAccessToken(ctx context.Context, reqBody RevokeAccessTokenRequest) error
func RevokeRefreshToken ¶
func RevokeRefreshToken(ctx context.Context, req RevokeRefreshTokenRequest) error
Types ¶
type AppValidationTokenRequest ¶
type AppValidationTokenRequest struct { // ClientID is the package name of your app ClientID string // ClientSecret is secret generated as a JSON Web Token that uses the secret key generated by the WWDR portal. // It can also be generated using the GenerateClientSecret function provided in this package ClientSecret string // The authorization code received in an authorization response sent to your app. The code is single-use only and valid for five minutes. // Authorization code validation requests require this parameter. Code string }
AppValidationTokenRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens
type RevokeAccessTokenRequest ¶
type RevokeAccessTokenRequest struct { // ClientID is the "Services ID" value that you get when navigating to your "sign in with Apple"-enabled service ID ClientID string // ClientSecret is secret generated as a JSON Web Token that uses the secret key generated by the WWDR portal. // It can also be generated using the GenerateClientSecret function provided in this package ClientSecret string // AccessToken is the auth token given during a previous validation AccessToken string }
RevokeAccessTokenRequest is based off https://developer.apple.com/documentation/sign_in_with_apple/revoke_tokens
type RevokeRefreshTokenRequest ¶
type RevokeRefreshTokenRequest struct { // ClientID is the "Services ID" value that you get when navigating to your "sign in with Apple"-enabled service ID ClientID string // ClientSecret is secret generated as a JSON Web Token that uses the secret key generated by the WWDR portal. // It can also be generated using the GenerateClientSecret function provided in this package ClientSecret string // RefreshToken is the refresh token given during a previous validation RefreshToken string }
RevokeRefreshTokenRequest is based off https://developer.apple.com/documentation/sign_in_with_apple/revoke_tokens
type ValidationRefreshRequest ¶
type ValidationRefreshRequest struct { // ClientID is the "Services ID" value that you get when navigating to your "sign in with Apple"-enabled service ID ClientID string // ClientSecret is secret generated as a JSON Web Token that uses the secret key generated by the WWDR portal. // It can also be generated using the GenerateClientSecret function provided in this package ClientSecret string // RefreshToken is the refresh token given during a previous validation RefreshToken string }
ValidationRefreshRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens
type ValidationTokenResponse ¶
type ValidationTokenResponse struct { AccessToken string `json:"access_token"` IDToken string `json:"id_token"` RefreshToken string `json:"refresh_token"` TokenType string `json:"token_type"` }
ValidationTokenResponse https://developer.apple.com/documentation/sign_in_with_apple/tokenresponse
func VerifyAppToken ¶
func VerifyAppToken(ctx context.Context, reqBody AppValidationTokenRequest) (*ValidationTokenResponse, error)
func VerifyRefreshToken ¶
func VerifyRefreshToken(ctx context.Context, req ValidationRefreshRequest) (*ValidationTokenResponse, error)
func VerifyWebToken ¶
func VerifyWebToken(ctx context.Context, reqBody WebValidationTokenRequest) (*ValidationTokenResponse, error)
type WebValidationTokenRequest ¶
type WebValidationTokenRequest struct { // ClientID is the "Services ID" value that you get when navigating to your "sign in with Apple"-enabled service ID ClientID string // ClientSecret is secret generated as a JSON Web Token that uses the secret key generated by the WWDR portal. // It can also be generated using the GenerateClientSecret function provided in this package ClientSecret string // Code is the authorization code received from your application’s user agent. // The code is single use only and valid for five minutes. Code string // RedirectURI is the destination URI the code was originally sent to. // Redirect URLs must be registered with Apple. You can register up to 10. Apple will throw an error with IP address // URLs on the authorization screen, and will not let you add localhost in the developer portal. RedirectURI string }
WebValidationTokenRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens