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(firebase_auth): Update federated-auth.md for Facebook limited login #13416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all 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
16 changes: 14 additions & 2 deletions docs/auth/federated-auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,25 @@ with the Facebook App ID and Secret set.

Future<UserCredential> signInWithFacebook() async {
// Trigger the sign-in flow
final rawNonce = _generateRandomString(); // You should implement this function
final nonce = _sha256ofString(rawNonce); // You should implement this function
final LoginResult loginResult = await FacebookAuth.instance.login();

// Create a credential from the access token
final OAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(loginResult.accessToken.token);
OAuthCredential? facebookAuthCredential;
if (loginResult.accessToken is LimitedToken) {
facebookAuthCredential = OAuthCredential(
providerId: 'facebook.com',
signInMethod: 'oauth',
idToken: loginResult.accessToken.tokenString,
rawNonce: rawNonce,
);
} else {
facebookAuthCredential = FacebookAuthProvider.credential(loginResult.accessToken.token);
}

// Once signed in, return the UserCredential
return FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
return FirebaseAuth.instance.signInWithCredential(facebookAuthCredential!);
}
```

Expand Down