--- title: "Get-MSGraphAccessToken" slug: "get-msgraphaccesstoken" updated: 2024-08-21T15:51:49Z published: 2024-08-21T15:51:49Z canonical: "support.nectarcorp.com/get-msgraphaccesstoken" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.nectarcorp.com/llms.txt > Use this file to discover all available pages before exploring further. # Get-MSGraphAccessToken Get a Microsoft Graph access token for a given MS tenant. Needed to run other Graph API queries. ## Syntax ``` Get-MSGraphAccessToken -MSClientID -MSClientSecret -MSTenantID -N10Cert -CertFriendlyName -CertThumbprint -CertPath -CertStore ``` ## Examples ### Example 1 ``` $AuthToken = Get-MSGraphAccessToken -MSClientID 41a228ad-db6c-4e4e-4184-6d8a1175a35f -MSClientSecret 43Rk5Xl3K349w-pFf0i_Rt45Qd~ArqkE32. -MSTenantID 17e1e614-8119-48ab-8ba1-6ff1d94a6930 ``` Obtains an authtoken for the given tenant using secret-based auth and saves the results for use in other commands in a variable called $AuthToken ### Example 2 ``` $AuthToken = Get-MSGraphAccessToken -MSClientID 029834092-234234-234234-23442343 -MSTenantID 234234234-234234-234-23-42342342 -CertFriendlyName 'CertAuth' -CertStore LocalMachine ``` Obtains an authtoken for the given tenant using certificate auth and saves the results for use in other commands in a variable called $AuthToken ## Parameters **-MSClientID ** The MS client ID for the application granted access to Azure AD. | Parameter | Value | | --- | --- | | Required | true | | Position | 1 | | Required | true | | Default Value | None | | Accept pipeline input? | true (ByPropertyName) | | Accept wildcard characters? | false | **-MSClientSecret ** The MS client secret for the application granted access to Azure AD. | Parameter | Value | | --- | --- | | Required | false | | Position | 2 | | Required | false | | Default Value | None | | Accept pipeline input? | true (ByPropertyName) | | Accept wildcard characters? | false | **-MSTenantID ** The MS tenant ID for the O365 customer granted access to Azure AD. | Parameter | Value | | --- | --- | | Required | true | | Position | 3 | | Required | true | | Default Value | None | | Accept pipeline input? | true (ByPropertyName) | | Accept wildcard characters? | false | **-N10Cert ** | Parameter | Value | | --- | --- | | Required | false | | Position | named | | Required | false | | Default Value | False | | Accept pipeline input? | false | | Accept wildcard characters? | false | **-CertFriendlyName ** The friendly name of an installed certificate to be used for certificate authentication. Can be used instead of MSClientSecret | Parameter | Value | | --- | --- | | Required | false | | Position | 4 | | Required | false | | Default Value | None | | Accept pipeline input? | false | | Accept wildcard characters? | false | **-CertThumbprint ** The thumbprint of an installed certificate to be used for certificate authentication. Can be used instead of MSClientSecret | Parameter | Value | | --- | --- | | Required | false | | Position | 5 | | Required | false | | Default Value | None | | Accept pipeline input? | false | | Accept wildcard characters? | false | **-CertPath ** The path to a PFX certificate to be used for certificate authentication. Can be used instead of MSClientSecret | Parameter | Value | | --- | --- | | Required | false | | Position | 6 | | Required | false | | Default Value | None | | Accept pipeline input? | false | | Accept wildcard characters? | false | **-CertStore ** The certificate store to be used for certificate authentication. Select either LocalMachine or CurrentUser. Used in conjunction with CertThumbprint or CertFriendlyName Can be used instead of MSClientSecret. | Parameter | Value | | --- | --- | | Required | false | | Position | 7 | | Required | false | | Default Value | CurrentUser | | Accept pipeline input? | false | | Accept wildcard characters? | false |