Flutter App, Login with Microsoft Account and FirebaseAuth

Sérgio Ricardo Rodrigues Teixeira 20 Reputation points
2023-09-14T14:13:17.8466667+00:00

Hi. I'm trying to implement a login flow with Microsoft Account on Azure Active Directory, using Firebase Auth in a Flutter app, but it keeps giving me an error.

My code is basically this (it's Dart, but it wasn't an option in "development language" dropdown button).

I click Login, the popup shows, I insert my e-mail, it sends a verification code to my e-mail, I insert the code.

Now it asks me to log in with an administrator account because I don't have permission to access the resources in my organization.

It gives me another option, to return to the app without granting authorization.

When I click it, an error shows:

AADSTS900561: The endpoint only accepts POST requests. Received a GET request.

Request ID: dc57b575-55a9-4b4c-9e31-8be7b88a0500
Correlation ID: f567a231-9c6c-43ed-91c8-9ef06569c212

I don't have a clue what can I do to make this thing work. Tried searching on the web, reading documentation, even asking for Bing AI, ChatGPT and Bard. They don't have any clue either.

I beg you for help. Thanks in advance.

final microsoftProvider = OAuthProvider('microsoft.com');
    microsoftProvider.setCustomParameters({
      'tenant': 'tenant ID',
    });
    microsoftProvider.addScope('mail.read');

      var credential =
          await FirebaseAuth.instance.signInWithPopup(microsoftProvider);
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,526 Reputation points Moderator
    2023-09-19T05:51:15.5366667+00:00

    Hello @Sérgio Ricardo Rodrigues Teixeira , the AADSTS900561 error may be caused by your application redirecting you to the Azure AD token endpoint. However, the first issue here is that you're being asked to provide admin consent which you cannot. In order to solve this you need to reach an admin for your tenant so he can grant tenant wide admin consent or grant consent on behalf of a single user.

    Let us know if you need additional assistance. If the answer was helpful, please accept it and rate it so that others facing a similar issue can easily find a solution.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.