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.
On the web, the provider's page opens in a popup and comes back to the site's /_nn/oauth, such as https://cafe.example/_nn/oauth: register that as a redirect URI (Google) or return URL (Apple).
Index ¶
Constants ¶
This section is empty.
Variables ¶
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. The web uses it too. Google only.
AndroidClient string `json:"androidClient,omitempty"`
// AppleServicesID is Apple's Services ID, for Sign in with Apple on
// the web. Apple only.
AppleServicesID string `json:"appleServicesID,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, on iOS and on the web (with AppleServicesID). 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 (and
// the Services ID, for the web), 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.