Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
New-PartnerAccessToken
- Module:
- PartnerCenter Module
Acquires an access token from Azure Active Directory.
Syntax
AccessToken
New-PartnerAccessToken
-AccessToken <String>
-ApplicationId <String>
-Scopes <String[]>
[-Credential <PSCredential>]
[-Environment <EnvironmentName>]
[-Tenant <String>]
[<CommonParameters>]
RefreshToken
New-PartnerAccessToken
-RefreshToken <String>
-Scopes <String[]>
[-ApplicationId <String>]
[-CertificateThumbprint <String>]
[-Credential <PSCredential>]
[-Environment <EnvironmentName>]
[-Module <ModuleName>]
[-ServicePrincipal]
[-Tenant <String>]
[<CommonParameters>]
ServicePrincipal
New-PartnerAccessToken
-ApplicationId <String>
-Credential <PSCredential>
-Scopes <String[]>
-Tenant <String>
[-Environment <EnvironmentName>]
[-ServicePrincipal]
[-UseAuthorizationCode]
[<CommonParameters>]
ServicePrincipalCertificate
New-PartnerAccessToken
-ApplicationId <String>
-CertificateThumbprint <String>
-Scopes <String[]>
-Tenant <String>
[-Environment <EnvironmentName>]
[-ServicePrincipal]
[-UseAuthorizationCode]
[<CommonParameters>]
User
New-PartnerAccessToken
-ApplicationId <String>
-Scopes <String[]>
[-Environment <EnvironmentName>]
[-Tenant <String>]
[-UseAuthorizationCode]
[-UseDeviceAuthentication]
[<CommonParameters>]
ByModule
New-PartnerAccessToken
-Module <ModuleName>
[-Environment <EnvironmentName>]
[-RefreshToken <String>]
[-Tenant <String>]
[-UseAuthorizationCode]
[<CommonParameters>]
Description
Acquires an access token from Azure Active Directory.
Examples
Example 1: Generating a new access token
PS C:\> $credential = Get-Credential
PS C:\> New-PartnerAccessToken -ApplicationId 'xxxx-xxxx-xxxx-xxxx' -Scopes 'https://api.partnercenter.microsoft.com/user_impersonation' -ServicePrincipal -Credential $credential -Tenant 'xxxx-xxxx-xxxx-xxxx' -UseAuthorizationCode
The first command gets the service principal credentials (application identifier and service principal secret), and then stores them in the $credential variable. The second command will request a new access token from Azure Active Directory. When using the UseAuthorizationCode parameter you will be prompted to authentication interactively using the authorization code flow. The redirect URI value will generated dynamically. This generation process will attempt to find a port between 8400 and 8999 that is not in use. Once an available port has been found, the redirect URL value will be constructed (e.g. http://localhost:8400). So, it is important that you have configured the redirect URI value for your Azure Active Directory application accordingly.
Example 2: Generating an access token using a refresh token
PS C:\> $credential = Get-Credential
PS C:\> $refreshToken = '<refreshToken>'
PS C:\> New-PartnerAccessToken -ApplicationId 'xxxx-xxxx-xxxx-xxxx' -Credential $credential -RefreshToken $refreshToken -Scopes 'https://api.partnercenter.microsoft.com/user_impersonation' -ServicePrincipal -Tenant 'xxxx-xxxx-xxxx-xxxx'
The first command gets the service principal credentials (application identifier and service principal secret), and then stores them in the $credential variable. The third command will generate a new access token using the service principal credentials stored in the $credential variable and the refresh token stored in the $refreshToken variable for authentication.
Parameters
-AccessToken
The access token for Partner Center.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ApplicationId
The application identifier to be used during authentication.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ClientId |
Parameter sets
-CertificateThumbprint
Certificate Hash (Thumbprint)
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Credential
Credentials that represents the service principal.
Parameter properties
| Type: | PSCredential |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Environment
The environment use for authentication.
Parameter properties
| Type: | EnvironmentName |
| Default value: | None |
| Accepted values: | AzureCloud, AzureChinaCloud, AzureGermanCloud, AzurePPE, AzureUSGovernment |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | EnvironmentName |
Parameter sets
-Module
The module that an access token is being generated.
Parameter properties
| Type: | ModuleName |
| Default value: | None |
| Accepted values: | ExchangeOnline |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | ModuleName |
Parameter sets
-RefreshToken
The refresh token to use during authentication.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Scopes
Scopes requested to access a protected API.
Parameter properties
| Type: | String[] |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-ServicePrincipal
Indicates that this account authenticates by providing service principal credentials.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
Parameter sets
-Tenant
The identifier of the Azure AD tenant.
Parameter properties
| Type: | String |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | Domain, TenantId |
Parameter sets
-UseAuthorizationCode
Use the authorization code flow during authentication.
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | AuthCode |
Parameter sets
-UseDeviceAuthentication
Use device code authentication instead of a browser control
Parameter properties
| Type: | SwitchParameter |
| Default value: | None |
| Supports wildcards: | False |
| DontShow: | False |
| Aliases: | DeviceCode, DeviceAuth, Device |
Parameter sets
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
