Gerenios / AADInternals

AADInternals PowerShell module for administering Azure AD and Office 365
http://aadinternals.com/aadinternals
MIT License
1.24k stars 214 forks source link

"Code not received" error when using Get-AADIntAccessTokenForOneDrive #12

Closed pawp81 closed 2 years ago

pawp81 commented 3 years ago

Trying to obtain AT for OneDrive with PRT cookie ends up with following error:

Code not received!
At C:\Program Files\WindowsPowerShell\Modules\AADInternals\0.4.6\PRT_Utils.ps1:409 char:13
+             throw "Code not received!"
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Code not received!:String) [], RuntimeException
    + FullyQualifiedErrorId : Code not received!
After digging deeper Azure AD error is: InvalidReplyTo.

Command used. I am not using tenant domain, but tenant name. I tried with tenantID and received the same error Get-AADIntAccessTokenForOneDrive -PRTToken ey[cut]fQ9s= -Tenant tenantname

Request sent captured with Fiddler: GET /Common/oauth2/authorize?resource=https://tenantname-my.sharepoint.com/&client_id=ab9b8c07-8f02-4f72-87fa-80105867a763&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client-request-id=7f3608b7-9e34-4de1-b261-82b0d9eb174f&mscrid=7f3608b7-9e34-4de1-b261-82b0d9eb174f&sso_nonce= HTTP/1.1 x-ms-RefreshTokenCredential: ey[cut]fQ9s= Host: login.microsoftonline.com

NestoriSyynimaa commented 3 years ago

It seems that Microsoft have changed something, getting access token with PRTs doesn't work as expected. At least it doesn't work for OneDrive.