Skip to content

Commit 2371d2d

Browse files
fix(auth): deprecate Microsoft provider method not used for authentication (#17094)
1 parent 5255761 commit 2371d2d

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

‎packages/firebase_auth/firebase_auth_platform_interface/lib/src/providers/microsoft_auth.dart

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ const _kProviderId = 'microsoft.com';
2424
/// .then(...);
2525
/// ```
2626
///
27-
/// If authenticating with Microsoft via a 3rd party, use the returned
28-
/// `accessToken` to sign-in or link the user with the created credential, for
29-
/// example:
30-
///
27+
/// For native apps, you may also sign-in with [signInWithProvider]. Ensure you have
28+
/// an app configured in the Microsoft Azure portal.
29+
/// See Firebase documentation for more information: https://firebase.google.com/docs/auth/flutter/federated-auth?#microsoft
3130
/// ```dart
32-
/// String accessToken = '...'; // From 3rd party provider
33-
/// var microsoftAuthCredential = MicrosoftAuthProvider.credential(accessToken);
34-
///
35-
/// FirebaseAuth.instance.signInWithCredential(microsoftAuthCredential)
36-
/// .then(...);
31+
/// MicrosoftAuthProvider microsoftProvider = MicrosoftAuthProvider();
32+
/// microsoftProvider.setCustomParameters({'tenant': 'TENANT ID FROM AZURE PORTAL'},);
33+
/// await FirebaseAuth.instance.signInWithProvider(microsoftProvider);
3734
/// ```
3835
class MicrosoftAuthProvider extends AuthProvider {
3936
/// Creates a new instance.
4037
MicrosoftAuthProvider() : super(_kProviderId);
4138

4239
/// Create a new [MicrosoftAuthCredential] from a provided [accessToken];
40+
@Deprecated(
41+
'`credential()` has been deprecated. Sign-in cannot be directly achieved with OAuth access token based credentials for Microsoft. Please use `signInWithProvider(MicrosoftAuthProvider)` instead.',
42+
)
4343
static OAuthCredential credential(String accessToken) {
4444
return MicrosoftAuthCredential._credential(
4545
accessToken,
@@ -85,16 +85,15 @@ class MicrosoftAuthProvider extends AuthProvider {
8585
}
8686
}
8787

88-
/// The auth credential returned from calling
89-
/// [MicrosoftAuthProvider.credential].
88+
// ignore: deprecated_member_use_from_same_package
89+
/// [MicrosoftAuthProvider.credential] returns a [MicrosoftAuthCredential] instance.
9090
class MicrosoftAuthCredential extends OAuthCredential {
9191
MicrosoftAuthCredential._({
9292
required String accessToken,
9393
}) : super(
9494
providerId: _kProviderId,
9595
signInMethod: _kProviderId,
9696
accessToken: accessToken);
97-
9897
factory MicrosoftAuthCredential._credential(String accessToken) {
9998
return MicrosoftAuthCredential._(accessToken: accessToken);
10099
}

0 commit comments

Comments
 (0)