Skip to content
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

docs(auth, apple): show how to use credentialWithIDToken() #12940

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/auth/federated-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,32 @@ Future<UserCredential> signInWithApple() async {
}
```

#### Apple platform sign-in only

Apple sign-in on iOS+ platforms can also be achieved with the following method:

```dart
// Create a nonce
String rawNonce = createNonce();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some guidance on generating it would be nice. At least clarify that the reader needs to implement this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinthecheung - thanks, I've updated the docs 👍

// Create a hash SHA-256 string of the nonce. Consider using the `crypto` package on pub.dev registry
String hashSHA256String = createHashSHA256String(rawNonce);
// Use the hash SHA-256 string of the nonce to get the idToken. Consider using the `sign_in_with_apple` plugin on pub.dev registry
Lyokone marked this conversation as resolved.
Show resolved Hide resolved
String idToken = await getIdToken();
russellwheatley marked this conversation as resolved.
Show resolved Hide resolved

final fullName = AppleFullPersonName(
familyName: 'Name',
givenName: 'Your',
);
// Use the `rawNonce` and `idToken` to get the credential
final credential = AppleAuthProvider.credentialWithIDToken(
idToken,
rawNonce,
fullName,
);

await FirebaseAuth.instance.signInWithCredential(credential);
```

### Revoke Apple auth tokens {:#revoke-apple}

Apple sign-in on Apple platforms returns an authorization code that can be used
Expand Down
Loading