Is there an existing issue for this?
Which plugins are affected?
Auth
Which platforms are affected?
No response
Description
When using the GoogleAuthProvider and setting the profile scope to get the user's name does nothing. The 'displayName' is always null.
Reproducing the issue
Simply doing running the following agains the LIVE instance should show the described behaviour.
final provider = GoogleAuthProvider().addScope('email').addScope('profile');
FirebaseAuth.instance.signInWithProvider(provider);
In addition, I tried debugging this issue. When the GoogleAuthProvider is converted to a PigeonSignInProvider the scopes are lost. They are passed to native as null. The null is observed here:
|
Future<UserCredentialPlatform> signInWithProvider( |
|
AuthProvider provider, |
|
) async { |
|
try { |
|
// To extract scopes and custom parameters from the provider |
|
final convertedProvider = convertToOAuthProvider(provider); |
|
|
|
final result = await _api.signInWithProvider( |
|
pigeonDefault, |
|
PigeonSignInProvider( |
|
providerId: convertedProvider.providerId, |
|
scopes: convertedProvider is OAuthProvider |
|
? convertedProvider.scopes |
|
: null, |
|
customParameters: convertedProvider is OAuthProvider |
|
? convertedProvider.parameters |
|
: null, |
|
), |
|
); |
The root of the issue seems to be with:
|
AuthProvider convertToOAuthProvider(AuthProvider authProvider) { |
|
if (authProvider is MicrosoftAuthProvider) { |
|
final oAuthProvider = OAuthProvider(authProvider.providerId); |
|
oAuthProvider.setScopes(authProvider.scopes); |
|
oAuthProvider.setCustomParameters(authProvider.parameters); |
|
return oAuthProvider; |
|
} |
|
|
|
if (authProvider is GithubAuthProvider) { |
|
final oAuthProvider = OAuthProvider(authProvider.providerId); |
|
oAuthProvider.setScopes(authProvider.scopes); |
|
oAuthProvider.setCustomParameters(authProvider.parameters); |
|
return oAuthProvider; |
|
} |
|
|
|
if (authProvider is AppleAuthProvider) { |
|
final oAuthProvider = OAuthProvider(authProvider.providerId); |
|
oAuthProvider.setScopes(authProvider.scopes); |
|
oAuthProvider.setCustomParameters(authProvider.parameters); |
|
return oAuthProvider; |
|
} |
|
|
|
if (authProvider is TwitterAuthProvider) { |
|
final oAuthProvider = OAuthProvider(authProvider.providerId); |
|
oAuthProvider.setCustomParameters(authProvider.parameters); |
|
return oAuthProvider; |
|
} |
|
|
|
return authProvider; |
|
} |
It doesn't convert a GoogleAuthProvider to an OAuthProvider.
Firebase Core version
3.1.1
Flutter Version
3.22.2
Relevant Log Output
No response
Flutter dependencies
No response
Additional context and comments
No response
Is there an existing issue for this?
Which plugins are affected?
Auth
Which platforms are affected?
No response
Description
When using the
GoogleAuthProviderand setting theprofilescope to get the user's name does nothing. The 'displayName' is always null.Reproducing the issue
Simply doing running the following agains the LIVE instance should show the described behaviour.
In addition, I tried debugging this issue. When the
GoogleAuthProvideris converted to aPigeonSignInProviderthe scopes are lost. They are passed to native as null. The null is observed here:flutterfire/packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel/method_channel_firebase_auth.dart
Lines 380 to 398 in b1584aa
The root of the issue seems to be with:
flutterfire/packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel/utils/convert_auth_provider.dart
Lines 9 to 38 in b1584aa
It doesn't convert a
GoogleAuthProviderto anOAuthProvider.Firebase Core version
3.1.1
Flutter Version
3.22.2
Relevant Log Output
No response
Flutter dependencies
No response
Additional context and comments
No response