@@ -5,24 +5,24 @@ function Get-oAuthToken {
5
5
. DESCRIPTION
6
6
This Function connects to the Microsoft AAD OAuth endpoint and generates an OAuth token.
7
7
This token can then be used for authentication against the resource supplied In the parameters.
8
- . PARAMETER ClientID
9
- The ClientID of the application used for authentication against Azure AD.
10
- . PARAMETER ClientSecret
8
+ . PARAMETER ApplicationId
9
+ The ApplicationId of the application used for authentication against Azure AD.
10
+ . PARAMETER ApplicationKey
11
11
The Key generated within the application used for authentication against Azure AD.
12
12
This key should have rights to the resource supplied in the ResourceName parameter.
13
13
. PARAMETER TenantId
14
14
The TenantId of the Azure AD that you wish to authenticate against.
15
15
. PARAMETER ResourceName
16
16
The name of the resource that you want to generate a token for.
17
17
. EXAMPLE
18
- Get-ApiToken -ClientID '12345678-9012-3456-7890-123456789012' -ClientSecret 'AfXooIr8rswX24yrFXMrO4SbBgutwTtojAZEpQOaaaa=' -TenantId 'abcd4ffb-d0bc-1234-854a-114710c94dbb' -Resource 'https://test.onmicrosoft.com/apitest'
18
+ Get-ApiToken -ApplicationId '12345678-9012-3456-7890-123456789012' -ApplicationKey 'AfXooIr8rswX24yrFXMrO4SbBgutwTtojAZEpQOaaaa=' -TenantId 'abcd4ffb-d0bc-1234-854a-114710c94dbb' -Resource 'https://test.onmicrosoft.com/apitest'
19
19
. NOTES
20
- Version 1.1
20
+ Version 1.2.0
21
21
#>
22
22
[Cmdletbinding ()]
23
23
Param (
24
- [Parameter (Mandatory = $true )][string ]$ClientID ,
25
- [Parameter (Mandatory = $true )][string ]$ClientSecret ,
24
+ [Parameter (Mandatory = $true )][string ]$ApplicationId ,
25
+ [Parameter (Mandatory = $true )][string ]$ApplicationKey ,
26
26
[Parameter (Mandatory = $true )][string ]$TenantId ,
27
27
[Parameter (Mandatory = $false )][string ]$ResourceName = " https://graph.windows.net" ,
28
28
[Parameter (Mandatory = $false )][boolean ]$ChinaAuth = $false
@@ -38,7 +38,7 @@ function Get-oAuthToken {
38
38
}
39
39
40
40
# Get an Oauth 2 access token based on client id, secret and tenant id
41
- $Body = @ {grant_type = " client_credentials" ; resource = $ResourceName ; client_id = $ClientID ; client_secret = $ClientSecret }
41
+ $Body = @ {grant_type = " client_credentials" ; resource = $ResourceName ; client_id = $ApplicationId ; client_secret = $ApplicationKey }
42
42
$AuthContext = Invoke-RestMethod - Method Post - Uri $LoginURL / $TenantId / oauth2/ token?api- version= 1.0 - Body $Body
43
43
Return " $ ( $AuthContext.token_type ) $ ( $AuthContext.access_token ) "
44
44
}
0 commit comments