# README
Apple 登录验证
根据code验证
var (
code string
uid string
)
//验证
secret, _ := apple.GenerateClientSecret(secret, teamID, clientID, keyID)
//
client := apple.NewClient()
vReq := apple.AppValidationTokenRequest{
ClientID: clientID,
ClientSecret: secret,
Code: code, // code值
}
var resp apple.ValidationResponse
// 验证
client.VerifyAppToken(context.Background(), vReq, &resp)
// 获取用户信息
unique, _ := apple.GetUniqueID(resp.IDToken)
// 验证是否同一个用户
if unique!=uid{
return
}
fmt.Println(unique)
# Functions
GenerateClientSecret generates the client secret used to make requests to the validation server.
GetClaims decodes the id_token response and returns the JWT claims to identify the user.
GetUniqueID decodes the id_token response and returns the unique subject ID to identify the user.
NewClient creates a Client object.
NewWithURL creates a Client object with a custom URL provided.
# Constants
AcceptHeader is the content that we are willing to accept.
ContentType is the one expected by Apple.
UserAgent is required by Apple or the request will fail.
ValidationURL is the endpoint for verifying tokens.
# Structs
AppValidationTokenRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens.
Client implements ValidationClient.
RefreshResponse is a subset of ValidationResponse returned by Apple.
ValidationRefreshRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens.
ValidationResponse is based off of https://developer.apple.com/documentation/signinwithapplerestapi/tokenresponse.
WebValidationTokenRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens.
# Interfaces
ValidationClient is an interface to call the validation API.