Skip to main content

util accesstoken get

Gets access token for the specified resource

Usage

m365 util accesstoken get [options]

Options

-r, --resource <resource>

The resource for which to retrieve an access token

--new

Retrieve a new access token to ensure that it's valid for as long as possible

-h, --help [help]

Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is options.

--query [query]

JMESPath query string. See http://jmespath.org/ for more information and examples.

-o, --output [output]

Output type. json, text, csv, md, none. Default json.

--verbose

Runs command with verbose logging.

--debug

Runs command with debug logging.

Remarks

tip

Instead of specifying the full URL of the resource, you can use one of the following shorthand identifiers: sharepoint, graph.

The util accesstoken get command returns an access token for the specified resource. If an access token has been previously retrieved and is still valid, the command will return the cached token. If you want to ensure that the returned access token is valid for as long as possible, you can force the command to retrieve a new access token by using the --new option.

Examples

Get access token for the Microsoft Graph

m365 util accesstoken get --resource https://graph.microsoft.com

Get access token for SharePoint Online using the shorthand identifier

m365 util accesstoken get --resource sharepoint

Get access token for Microsoft Graph using the shorthand identifier

m365 util accesstoken get --resource graph

Get a new access token for SharePoint Online

m365 util accesstoken get --resource https://contoso.sharepoint.com --new

Response

"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9.ewogICJhdWQiOiAiaHR0cHM6Ly9jb250b3NvLnNoYXJlcG9pbnQuY29tIiwKICAiaXNzIjogImh0dHBzOi8vc3RzLndpbmRvd3MubmV0L2VhNjExNDcxLTE2ZTEtNDEwMS1hN2M0LTMzNTNmNjc1YTBkOC8iLAogICJpYXQiOiAxNjY3NTE2MDM1LAogICJuYmYiOiAxNjY3NTE2MDM1LAogICJleHAiOiAxNjY3NTIwODE3LAogICJhY3IiOiAiMSIsCiAgImFpbyI6ICJBVFFBeS84VEFBQUE0NFZrYm45YWNXa3Y1RVIzT1M1R3N3WWxZdzlHRlpvQmtQUG50VHhlTD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