Request-PnPAccessToken
SYNOPSIS
Requests an OAuth Access token.
SYNTAX
Request-PnPAccessToken [-ClientId <String>] [-Resource <String>] [-Scopes <String[]]>] [-Decoded] [-Credentials <PSCredential>] [-TenantUrl <String>]
DESCRIPTION
Returns an access token using the password grant, using the PnP O365 Management Shell client id by default and the AllSites.FullControl scope by default.
EXAMPLES
EXAMPLE 1
Request-PnPAccessToken
Returns the access token using the default client id and scope.
EXAMPLE 2
Request-PnPAccessToken -ClientId 26e29fec-aa10-4f99-8381-d96cddc650c2
Returns the access token using the specified client id and the default scope of AllSites.FullControl
EXAMPLE 3
Request-PnPAccessToken -ClientId 26e29fec-aa10-4f99-8381-d96cddc650c2 -Scopes Group.ReadWrite.All
Returns the access token using the specified client id and the specified scope.
EXAMPLE 4
Request-PnPAccessToken -ClientId 26e29fec-aa10-4f99-8381-d96cddc650c2 -Scopes Group.ReadWrite.All, AllSites.FullControl
Returns the access token using the specified client id and the specified scopes.
PARAMETERS
-ClientId
The Azure Application Client Id to use to retrieve the token. Defaults to the PnP Office 365 Management Shell.
Type: String
Parameter Sets: (All)
Aliases: ApplicationId
Required: False
Position: Named
Default value: 31359c7f-bd7e-475c-86db-fdb8c937548e
Accept pipeline input: False
Accept wildcard characters: False
-Credentials
Optional credentials to use when retrieving the access token. If not present you need to connect first with Connect-PnPOnline.
Type: PSCredential
Parameter Sets: (All)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Decoded
Returns the token in a decoded / human-readable manner.
Type: SwitchParameter
Parameter Sets: (All)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Scopes
The scopes to retrieve the token for. Defaults to AllSites.FullControl
Type: String[]
Parameter Sets: (All)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-TenantUrl
Optional tenant URL to use when retrieving the access token. The Url should be in the shape of https://yourtenant.sharepoint.com. See examples for more info.
Type: String
Parameter Sets: (All)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-AzureEnvironment
The Azure environment to use for authentication, the defaults to 'Production' which is the main Azure environment.
Type: AzureEnvironment
Parameter Sets: (All)
Aliases:
Accepted values: Production, PPE, China, Germany, USGovernment, USGovernmentHigh, USGovernmentDoD
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False