Skip to content

[firebase_auth]: GoogleAuthProvider scopes don't seem to do anything #13012

@jellynoone

Description

@jellynoone

Is there an existing issue for this?

  • I have searched the existing issues.

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

Metadata

Metadata

Assignees

Labels

platform: allIssues / PRs which are for all platforms.plugin: authresolution: fixedA fix has been merged or is pending merge from a PR.type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions