Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exception calling "AcquireToken" with "4" argument(s): "AADSTS50001: The application named https://myappwithapi/Login was not found in the tenant named me.onmicrosoft.com.
- #setup
- $TenantName = "mme.onmicrosoft.com"
- $clientId = "1950a258-227b-4e31-a9cf-717495945fc2" # Microsoft
- $clientId = "03faf8db-..........................." #
- $username = "me@me.onmicrosoft.com"
- $password = Read-Host -AsSecureString -Prompt "Enter Password"
- # add dlls
- $adal = "${env:ProgramFiles(x86)}Microsoft SDKsAzurePowerShellServiceManagementAzureServicesMicrosoft.IdentityModel.Clients.ActiveDirectory.dll"
- $adalforms = "${env:ProgramFiles(x86)}Microsoft SDKsAzurePowerShellServiceManagementAzureServicesMicrosoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll"
- $adalplatform = "${env:ProgramFiles(x86)}Microsoft SDKsAzurePowerShellServiceManagementAzureServicesMicrosoft.IdentityModel.Clients.ActiveDirectory.platform.dll"
- [System.Reflection.Assembly]::LoadFrom($adal) | Out-Null
- [System.Reflection.Assembly]::LoadFrom($adalforms) | Out-Null
- [System.Reflection.Assembly]::LoadFrom($adalplatform) | Out-Null
- #prep request
- $redirectUri = "urn:ietf:wg:oauth:2.0:oob" # Microsoft
- $resourceAppIdURI = "https://graph.windows.net"
- $authority = "https://login.windows.net/$TenantName"
- $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
- # Get Token prompting for creds
- $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Always")
- $authResult
- # Get the cred
- $cred = New-Object -TypeName 'Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential' -ArgumentList $username, $password
- #$cred = New-Object -TypeName 'Microsoft.IdentityModel.Clients.ActiveDirectory.UserPassCredential' -ArgumentList $username, $password
- $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $cred)
- $authResult
Add Comment
Please, Sign In to add comment