ThomasKur / M365Documentation

Automatic Microsoft 365 Documentation to simplify the life of admins and consultants.
Other
300 stars 45 forks source link

Loopback redirect URI #6

Closed techspence closed 2 years ago

techspence commented 3 years ago

Hey there. Getting an error when I try to Connect-M365Doc

Get-MsalToken: C:\Users\myusername\Documents\PowerShell\Modules\MSAL.PS\4.21.0.1\Get-MsalToken.ps1:304
Line |
 304 |  … ionResult = Get-MsalToken -Interactive -PublicClientApplication $Publ …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Only loopback redirect uri is supported, but msalxxxredactedxxx://auth/ was
     | found. Configure http://localhost or http://localhost:port both during app registration and when you
     | create the PublicClientApplication object. See https://aka.ms/msal-net-os-browser for details

Any ideas why this may be happening or how to fix? Note, this is with PowerShell 7.

ThomasKur commented 3 years ago

It looks like .NET Core needs another redirect URI. Can you try this:

$params = @{
        ClientId    = "37f82fa9-674e-4cae-9286-4b21eb9a6389"
        RedirectUri = "http://localhost"
    }

 $token = Get-MsalToken @params

 Connect-M365Doc -token $token

If this works I will update the module.

techspence commented 3 years ago

That did it. I'm able to successfully connect. Thanks!

ThomasKur commented 2 years ago

New version is published to PSGallery. This should work now.