Get-PnPAccessToken
SYNOPSIS
Returns the current Microsoft Graph OAuth Access token. If a Resource Type Name or Resource URL is specified, it will fetch the access token of the specified resource.
SYNTAX
Get-PnPAccessToken [-ResourceTypeName] [-ResourceUrl] [-Decoded] [-Scopes] [-Connection <PnPConnection>]
DESCRIPTION
Gets the OAuth 2.0 Access Token.
EXAMPLES
EXAMPLE 1
Get-PnPAccessToken
Gets the OAuth 2.0 Access Token to consume the Microsoft Graph API
EXAMPLE 2
Get-PnPAccessToken -Decoded
Gets the OAuth 2.0 Access Token to consume the Microsoft Graph API and shows the token with its content decoded
EXAMPLE 3
Get-PnPAccessToken -ResourceTypeName SharePoint
Gets the OAuth 2.0 Access Token to consume the SharePoint APIs and perform CSOM operations.
EXAMPLE 4
Get-PnPAccessToken -ResourceTypeName ARM
Gets the OAuth 2.0 Access Token to consume the Azure Resource Manager APIs and perform related operations. In PnP, you can use them in cmdlets related to Flow and PowerPlatform etc.
EXAMPLE 5
Get-PnPAccessToken -ResourceUrl "https://management.azure.com/.default"
Gets the OAuth 2.0 Access Token to consume the SharePoint APIs and perform CSOM operations.
PARAMETERS
-ResourceTypeName
Specify the Resource Type for which you want the access token. If not specified, it will by default return a Microsoft Graph access token.
Type: ResourceTypeName
Parameter Sets: Resource Type Name, Resource Type Name (decoded)
Accepted values: Graph, SharePoint, ARM
Required: False
Position: Named
Default value: Graph
Accept pipeline input: False
Accept wildcard characters: False
-ResourceUrl
Specify the Resource URL for which you want the access token, i.e. https://graph.microsoft.com/.default. If not specified, it will by default return a Microsoft Graph access token.
Type: String
Parameter Sets: Resource Url, Resource Url (decoded)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Decoded
Returns the details from the access token in a decoded manner
Type: SwitchParameter
Parameter Sets: Resource Type Name (decoded), Resource Url (decoded)
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Connection
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection.
Type: PnPConnection
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