Documentation
¶
Index ¶
- Constants
- func GetApplePrivateKeyFromFile(filename string) (privateKey string, err error)
- func NewAppleOAuth(inputConfig *AppleOAuthConfig) *appleOAuthReceiverArgument
- type AppleIDTokenInfo
- type AppleOAuthConfig
- type AppleOAuthMethod
- type AppleValidateAuthorizationCodeResponse
- type AppleValidateRefreshTokenResponse
- type OptionAppleGenerateOAuthURL
- type OptionAppleGetIDTokenInfoWithPublicKeyValidation
- type ResponseApplePublicKey
Constants ¶
View Source
const ( // URL for Apple OAuth OAuthURL = "https://appleid.apple.com/auth/authorize" // URL for fetch Apple's public key for verifying token signature PublicKeyURL = "https://appleid.apple.com/auth/keys" // URL for generate and validate tokens ValidateTokenURL = "https://appleid.apple.com/auth/token" // URL for revoke tokens RevokeTokenURL = "https://appleid.apple.com/auth/revoke" )
View Source
const ( PlatformWeb = "web" PlatformApp = "app" )
View Source
const ( TypeAccessToken = "access_token" TypeRefreshToken = "refresh_token" )
!RevokeToken
Variables ¶
This section is empty.
Functions ¶
func GetApplePrivateKeyFromFile ¶ added in v1.0.7
!GetApplePrivateKeyFromFile
func NewAppleOAuth ¶
func NewAppleOAuth(inputConfig *AppleOAuthConfig) *appleOAuthReceiverArgument
Types ¶
type AppleIDTokenInfo ¶
type AppleIDTokenInfo struct { Issuer string `json:"iss"` Subject string `json:"sub"` Audience string `json:"aud"` IssuedAt int64 `json:"iat"` ExpiresAt int64 `json:"exp"` Nonce *string `json:"nonce,omitempty"` NonceSupported *bool `json:"nonce_supported,omitempty"` Email *string `json:"email,omitempty"` EmailVerified *bool `json:"email_verified,omitempty"` IsPrivateEmail *bool `json:"is_private_email,omitempty"` RealUserStatus *int `json:"real_user_status,omitempty"` TransferSub *string `json:"transfer_sub,omitempty"` CHash *string `json:"c_hash,omitempty"` AtHash *string `json:"at_hash,omitempty"` AuthTime *int64 `json:"auth_time,omitempty"` }
!GetIDTokenInfo
func GetIDTokenInfo ¶
func GetIDTokenInfo(idToken string) (returnData AppleIDTokenInfo, err error)
type AppleOAuthConfig ¶
type AppleOAuthConfig struct { // Client ID from apple developer account ex. com.parinyapt.ptgu ClientID string // Redirect URL that config for apple sign in ex. https://auth.prinpt.com/oauth/apple/callback RedirectURL string // Team ID from apple developer account TeamID string // 10 char of .p8 file name KeyID string // Key from .p8 file PrivateKey string }
type AppleOAuthMethod ¶
type AppleOAuthMethod interface { // GenerateOAuthURL is a function to generate oauth url for user to login // Condition for generate oauth url (https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms) GenerateOAuthURL(option OptionAppleGenerateOAuthURL) (oauthURL string) // GenerateClientSecret is a function to generate client secret for validate token GenerateClientSecret(expireIn time.Duration) (clientSecret string, err error) // GetIDTokenInfo is a function to get information from id token GetIDTokenInfo(idToken string) (returnData AppleIDTokenInfo, err error) // GetIDTokenInfoWithPublicKeyValidation is a function to get verify id token from apple and get information from id token GetIDTokenInfoWithPublicKeyValidation(idToken string, option OptionAppleGetIDTokenInfoWithPublicKeyValidation) (returnData AppleIDTokenInfo, isValidatePass bool, err error) // GetApplePublicKey is a function to get apple's public key for verifying token signature GetApplePublicKey(kid string) (returnData ResponseApplePublicKey, err error) GetApplePrivateKeyFromFile(filename string) (privateKey string, err error) // ValidateAuthorizationCode is a function to validate authorization code from apple and get access token / id token / refresh token [required platform = PlatformWeb or PlatformApp] ValidateAuthorizationCode(authorizationCode string, platform string) (returnData AppleValidateAuthorizationCodeResponse, err error) // ValidateRefreshToken is a function to validate refresh token from apple and get access token / id token ValidateRefreshToken(refreshToken string) (returnData AppleValidateRefreshTokenResponse, err error) // RevokeToken is a function to revoke token from apple [required tokenType = TypeAccessToken or TypeRefreshToken] RevokeToken(token string, tokenType string) (err error) }
type AppleValidateAuthorizationCodeResponse ¶
type AppleValidateAuthorizationCodeResponse struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` IDToken string `json:"id_token"` RefreshToken string `json:"refresh_token"` }
!ValidateAuthorizationCode
type AppleValidateRefreshTokenResponse ¶
type AppleValidateRefreshTokenResponse struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` ExpiresIn int `json:"expires_in"` IDToken string `json:"id_token"` }
!ValidateRefreshToken
type OptionAppleGenerateOAuthURL ¶
type OptionAppleGenerateOAuthURL struct { ResponseType []string ResponseMode string Scope []string State string }
!GenerateOAuthURL
type OptionAppleGetIDTokenInfoWithPublicKeyValidation ¶
type OptionAppleGetIDTokenInfoWithPublicKeyValidation struct { NotIssuedBeforeTime time.Time ExpiresAfterIssuedIn time.Duration }
!GetIDTokenInfoWithPublicKeyValidation
type ResponseApplePublicKey ¶
type ResponseApplePublicKey struct { Kty string `json:"kty"` Kid string `json:"kid"` Use string `json:"use"` Alg string `json:"alg"` N string `json:"n"` E string `json:"e"` }
!GetApplePublicKey
func GetApplePublicKey ¶
func GetApplePublicKey(kid string) (returnData ResponseApplePublicKey, err error)
Click to show internal directories.
Click to hide internal directories.