-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make documentation more beginner-friendly #48
Comments
Yes please, give more info about the options. |
yeah, @mlynch Hello, |
Also I had a question related to this. I'd like to know if there is any additional verification that I need to do with the returned "authorizationCode". Or if I get an "authorizationCode" and an "identityToken" back then can I assume that it is a verified and valid login? |
Below is the information I gathered while working on the Apple Sign In integration. Authentication Request OptionsOptions look like this:
clientId: For native app: the application ID, same as “appId” in capacitor config. For web app: a client ID assigned to it after creating a new identity record for the website in Certificates, Identifiers & Profiles, see also About Sign in with Apple. redirectUri: As I understand, state: used as CSRF token:
Note: probably this is more relevant for the sign in process in the web app, not sure if there is a way to hack into the sign in when it is performed in the native app (as request/response here happen on the level of the Apple platform code). Note: plugin actually does not return nonce: it is encoded into the “identityToken” that can be decoded (JWT token) and compared on the server:
This is to prevent replay attacks: a network sniffer records Apple response and then a recorded response is sent to the app to get the account access. References:
Authentication Response DataWe have following fields returned:
familyName, givenName, email user name and email, returned only on first sign in request ("null"s here after that) user: The unique Apple’s user ID (also it is unique for your development team, so other developers/app would have a different ID for the same user). See: Authenticating Users with Sign in with Apple Note: for the user identification we are actually forced to use user ID as familyName, givenName and email are only returned on first sign in. Following sign ins have “null”s here. Update: it looks like email is also present inside the identityToken, see Retrieve the User’s Information from Apple ID Servers:
identityToken: should be verified by the app backend, see: Verifying a User. Can be used to request user information from the Apple server. authorizationCode: can be used by the app backend for additional validation or to get new access tokens (to talk to Apple servers from the backend). See Verifying a User and Generate and Validate Tokens: Use this endpoint to either authorize a user by validating the authorization code received by your app, or by validating an existing refresh token to verify a user session or obtain access tokens. |
This is actually pretty simple, but it takes few hours to pick up pieces. Frontend integrationiOS platformimport { SignInWithAppleOptions } from '@capacitor-community/apple-sign-in'
const options: SignInWithAppleOptions = {
// The appId defined in capacitor.config.ts
clientId: 'com.your.webservice',
// Ignored for iOS Platform
redirectURI: '',
scopes: 'email name',
}; Web platformimport { SignInWithAppleOptions } from '@capacitor-community/apple-sign-in'
const options: SignInWithAppleOptions = {
// Service ID in your Apple Developer Account
clientId: 'com.your.webservice',
// This should be window.location origin because this plugin uses usePopup: true and data are sent back to opener
redirectURI: 'https://www.yourfrontend.com/login',
scopes: 'email name',
}; Android platformNot implemented, see #13 Backend integration
|
I feel like this repo is missing a lot of documentation.
No explanation for clientId, redirectURI, scopes, state and nonce params.
Also it's not clear that you have to create a new App ID on https://developer.apple.com/ with "Sign in with Apple" capability enabled etc.
The text was updated successfully, but these errors were encountered: