< Back

New-PartnerAccessToken

Sat Jan 18, 2020 6:34 pm

NAME New-PartnerAccessToken



SYNOPSIS

Acquires an access token from Azure Active Directory.





SYNTAX

New-PartnerAccessToken -AccessToken <String> -ApplicationId <String> [-Credential <PSCredential>] [-Environment

{AzureCloud | AzureChinaCloud | AzureGermanCloud | AzurePPE | AzureUSGovernment}] [-RefreshToken <String>] -Scopes

<String[]> [-Tenant <String>] [-UseAuthorizationCode] [<CommonParameters>]



New-PartnerAccessToken -ApplicationId <String> -Credential <PSCredential> [-Environment {AzureCloud |

AzureChinaCloud | AzureGermanCloud | AzurePPE | AzureUSGovernment}] [-RefreshToken <String>] -Scopes <String[]>

-ServicePrincipal -Tenant <String> [-UseAuthorizationCode] [<CommonParameters>]



New-PartnerAccessToken -ApplicationId <String> -CertificateThumbprint <String> [-Environment {AzureCloud |

AzureChinaCloud | AzureGermanCloud | AzurePPE | AzureUSGovernment}] [-RefreshToken <String>] -Scopes <String[]>

[-ServicePrincipal] -Tenant <String> [-UseAuthorizationCode] [<CommonParameters>]



New-PartnerAccessToken -ApplicationId <String> [-Environment {AzureCloud | AzureChinaCloud | AzureGermanCloud |

AzurePPE | AzureUSGovernment}] [-RefreshToken <String>] -Scopes <String[]> [-Tenant <String>]

[-UseAuthorizationCode] [-UseDeviceAuthentication] [<CommonParameters>]



New-PartnerAccessToken [-Environment {AzureCloud | AzureChinaCloud | AzureGermanCloud | AzurePPE |

AzureUSGovernment}] -Module {ExchangeOnline} [-RefreshToken <String>] [-Tenant <String>] [-UseAuthorizationCode]

[<CommonParameters>]





DESCRIPTION

Acquires an access token from Azure Active Directory.





PARAMETERS

-AccessToken <String>

The access token for Partner Center.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ApplicationId <String>

The application identifier to be used during authentication.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-CertificateThumbprint <String>

Certificate Hash (Thumbprint)



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Credential <PSCredential>

Credentials that represents the service principal.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Environment <EnvironmentName>

The environment use for authentication.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Module <ModuleName>

The module that an access token is being generated.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-RefreshToken <String>

The refresh token to use during authentication.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Scopes <String[]>

Scopes requested to access a protected API.



Required? true

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-ServicePrincipal [<SwitchParameter>]

Indicates that this account authenticates by providing service principal credentials.



Required? true

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Tenant <String>

The identifier of the Azure AD tenant.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-UseAuthorizationCode [<SwitchParameter>]

Use the authorization code flow during authentication.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-UseDeviceAuthentication [<SwitchParameter>]

Use device code authentication instead of a browser control



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None







OUTPUTS

Microsoft.Store.PartnerCenter.PowerShell.Models.Authentication.AuthResult







NOTES









----------- 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 ... ersonation' -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 ... ersonation' -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.







RELATED LINKS

Online Version: https://docs.microsoft.com/powershell/m ... ccessToken