Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Get-Authentication method is failing with the new AzureAD module. #2

Closed
punit-bhatt opened this issue May 6, 2019 · 1 comment
Assignees
Labels
bug Something isn't working copyKeys

Comments

@punit-bhatt
Copy link
Contributor

punit-bhatt commented May 6, 2019

The Get-Authentication method is failing with the new AzureAD modules. This is because there is no AcquireToken() method available anymore.
You need to replace it with the following method, keeping everything else the same.

### <summary>
### Gets the authentication result to key vaults.
### </summary>
function Get-Authentication
{
    # Vault resources endpoint
    $ArmResource = "https://vault.azure.net"
    # Well known client ID for AzurePowerShell used to authenticate scripts to Azure AD.
    $ClientId = "1950a258-227b-4e31-a9cf-717495945fc2"
    $RedirectUri = "urn:ietf:wg:oauth:2.0:oob"
    $AuthorityUri = "https://login.windows.net/$TenantId"
    $AuthContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" `
        -ArgumentList $AuthorityUri
    $PlatformParameters = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.PlatformParameters" `
        -ArgumentList "Auto", $null
    $AuthResult = $AuthContext.AcquireTokenAsync($ArmResource, $ClientId, $RedirectUri, $PlatformParameters)

    return $AuthResult.Result
}

This uses the method AcquireTokenAsync() which requires an additional parameter - PlatformParameters object.
This has been tested with AzureAD modules - 2.0.1.16 and 2.0.2.16

Originally posted by @punit1396 in #1 (comment)

@punit-bhatt punit-bhatt self-assigned this May 7, 2019
@punit-bhatt
Copy link
Contributor Author

punit-bhatt commented May 7, 2019

This issue has been resolved and the updated Authentication mechanism can be found in the CopyKeys-Az script.

@punit-bhatt punit-bhatt added bug Something isn't working copyKeys labels Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working copyKeys
Projects
None yet
Development

No branches or pull requests

1 participant