Documentation
¶
Overview ¶
Package signin signs them in with Apple or Google, using the phone's own sheet. On the phone:
nimbus native plugin add sign-in
u, err := signin.Google(ctx, signin.Options{
IOSClient: "123-ios.apps.googleusercontent.com",
AndroidClient: "123-web.apps.googleusercontent.com",
})
Then send u.IDToken to your server, which checks it with Verify. The other fields are for showing their name: anyone can forge what a phone sends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalid = errors.New("signin: invalid token")
ErrInvalid means the token isn't one to believe.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Nonce is a one-time value from your server. It comes back inside the
// ID token, so a stolen token can't be replayed.
Nonce string `json:"nonce,omitempty"`
// IOSClient is Google's iOS OAuth client ID. Google only.
IOSClient string `json:"iosClient,omitempty"`
// AndroidClient is Google's Web OAuth client ID: that kind, not the
// Android one, which only has to exist. Google only.
AndroidClient string `json:"androidClient,omitempty"`
}
Options says who's asking.
type User ¶
type User struct {
Provider string `json:"provider"` // "apple" or "google"
ID string `json:"id"` // theirs for life at that provider
Email string `json:"email"` // their address; Apple may give a private relay
Name string `json:"name"` // their name, when known
IDToken string `json:"idToken"` // for your server to check with Verify
// Code is Apple's one-time authorization code, for a server that wants
// refresh tokens. Empty for Google.
Code string `json:"code"`
}
User is who signed in.
func Apple ¶
Apple shows Sign in with Apple. It's iOS only: on Android the error has code plugin.Unavailable. Apple gives their name the first time only, and their email may be a private relay address.
type Verification ¶
type Verification struct {
// Audiences are your client IDs: Apple's is the app's bundle ID,
// Google's are the ones in Options. A token for another app is refused.
Audiences []string
// Nonce is the value you gave the phone. Empty skips the check.
Nonce string
}
Verification says what a token must be.
Click to show internal directories.
Click to hide internal directories.