applesign

package
v0.0.0-...-2042d3b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func GenerateClientSecret(signingKey, teamID, clientID, keyID string) (string, error)

GenerateClientSecret 生成用于向验证服务器发出请求的客户端机密。 该秘密将在180天后过期 signingKey-通过进入开发者部分的密钥部分获得的来自苹果的私钥 teamID-您的10个字符的团队ID clientID-您的服务ID,例如com.test.Services

func IDTokenClaims

func IDTokenClaims(idToken string) (jwt.MapClaims, error)

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

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL