< Back
Convert-GoogleOAuth2Code
Post
NAME Convert-GoogleOAuth2Code
SYNOPSIS
Exchanges an OAuth2 code for an access token.
SYNTAX
Convert-GoogleOAuth2Code [-Code] <String> [-ClientId] <String> [-ClientSecret] <String> [[-GrantType] <String>]
[[-ProfileLocation] <String>] [-Persist] [<CommonParameters>]
DESCRIPTION
This cmdlet exchanges an OAuth2 code for an access token and refresh token that can used
to authenticate a user to Google APIs.
PARAMETERS
-Code <String>
The one-time use authorization code received from Google.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientId <String>
The provided ClientId.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientSecret <String>
The provided ClientSecret.
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-GrantType <String>
The type of token being exchanged, in this case always authorization_code.
Required? false
Position? 4
Default value authorization_code
Accept pipeline input? false
Accept wildcard characters? false
-ProfileLocation <String>
The location where stored credentials are located. If this is not specified, the default location will be used.
Required? false
Position? 5
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Persist [<SwitchParameter>]
Indicates that the retrieved access tokens and client secret will be persisted on disk in an encrypted
format using the Windows DPAPI as well as the local in-memory cache (also encrypted).
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
None
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 1/17/2018
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$Code = Get-GoogleOAuth2Code -ClientId $Id -ClientSecret $Secret
Convert-GoogleOAuth2Code -Code $Code -ClientId $Id -ClientSecret $Secret -Persist
This example retrieves an authorization code and then exchanges it for long term access and refresh tokens. The
token data and client
secret are persisted to disk in an encrypted format.
RELATED LINKS
SYNOPSIS
Exchanges an OAuth2 code for an access token.
SYNTAX
Convert-GoogleOAuth2Code [-Code] <String> [-ClientId] <String> [-ClientSecret] <String> [[-GrantType] <String>]
[[-ProfileLocation] <String>] [-Persist] [<CommonParameters>]
DESCRIPTION
This cmdlet exchanges an OAuth2 code for an access token and refresh token that can used
to authenticate a user to Google APIs.
PARAMETERS
-Code <String>
The one-time use authorization code received from Google.
Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientId <String>
The provided ClientId.
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientSecret <String>
The provided ClientSecret.
Required? true
Position? 3
Default value
Accept pipeline input? false
Accept wildcard characters? false
-GrantType <String>
The type of token being exchanged, in this case always authorization_code.
Required? false
Position? 4
Default value authorization_code
Accept pipeline input? false
Accept wildcard characters? false
-ProfileLocation <String>
The location where stored credentials are located. If this is not specified, the default location will be used.
Required? false
Position? 5
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Persist [<SwitchParameter>]
Indicates that the retrieved access tokens and client secret will be persisted on disk in an encrypted
format using the Windows DPAPI as well as the local in-memory cache (also encrypted).
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
None
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 1/17/2018
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$Code = Get-GoogleOAuth2Code -ClientId $Id -ClientSecret $Secret
Convert-GoogleOAuth2Code -Code $Code -ClientId $Id -ClientSecret $Secret -Persist
This example retrieves an authorization code and then exchanges it for long term access and refresh tokens. The
token data and client
secret are persisted to disk in an encrypted format.
RELATED LINKS