File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -136,13 +136,25 @@ with the Facebook App ID and Secret set.
136
136
137
137
Future<UserCredential> signInWithFacebook() async {
138
138
// Trigger the sign-in flow
139
+ final rawNonce = _generateRandomString();
140
+ final nonce = sha256ofString(rawNonce);
139
141
final LoginResult loginResult = await FacebookAuth.instance.login();
140
142
141
143
// Create a credential from the access token
142
- final OAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(loginResult.accessToken.token);
144
+ OAuthCredential? facebookAuthCredential;
145
+ if (loginResult.accessToken is LimitedToken) {
146
+ facebookAuthCredential = OAuthCredential(
147
+ providerId: 'facebook.com',
148
+ signInMethod: 'oauth',
149
+ idToken: loginResult.accessToken.tokenString,
150
+ rawNonce: rawNonce,
151
+ );
152
+ } else {
153
+ facebookAuthCredential = FacebookAuthProvider.credential(loginResult.accessToken.token);
154
+ }
143
155
144
156
// Once signed in, return the UserCredential
145
- return FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
157
+ return FirebaseAuth.instance.signInWithCredential(facebookAuthCredential! );
146
158
}
147
159
```
148
160
You can’t perform that action at this time.
0 commit comments