/
model.go
83 lines (63 loc) · 3.78 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package apple
// WebValidationTokenRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens
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
}
// AppValidationTokenRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens
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
// 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
}
// ValidationRefreshRequest is based off of https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens
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
}
// ValidationResponse is based off of https://developer.apple.com/documentation/signinwithapplerestapi/tokenresponse
type ValidationResponse struct {
// (Reserved for future use) A token used to access allowed data. Currently, no data set has been defined for access.
AccessToken string `json:"access_token"`
// The type of access token. It will always be "bearer".
TokenType string `json:"token_type"`
// The amount of time, in seconds, before the access token expires. You can revalidate with the "RefreshToken"
ExpiresIn int `json:"expires_in"`
// The refresh token used to regenerate new access tokens. Store this token securely on your server.
RefreshToken string `json:"refresh_token"`
// A JSON Web Token that contains the user’s identity information.
IDToken string `json:"id_token"`
// Used to capture any error returned by the endpoint. Do not trust the response if this error is not nil
Error string `json:"error"`
}
// RefreshResponse is a subset of ValidationResponse returned by Apple
type RefreshResponse struct {
// (Reserved for future use) A token used to access allowed data. Currently, no data set has been defined for access.
AccessToken string `json:"access_token"`
// The type of access token. It will always be "bearer".
TokenType string `json:"token_type"`
// The amount of time, in seconds, before the access token expires. You can revalidate with this token
ExpiresIn int `json:"expires_in"`
// Used to capture any error returned by the endpoint. Do not trust the response if this error is not nil
Error string `json:"error"`
}