< Back
Update-GoogleOAuth2Token
Post
NAME Update-GoogleOAuth2Token
SYNOPSIS
Refreshes a Google OAuth2 access token that was retrieved with an authorization code.
SYNTAX
Update-GoogleOAuth2Token -ClientId <String> [-GrantType <String>] [-ProfileLocation <String>] [-Persist]
[<CommonParameters>]
Update-GoogleOAuth2Token -RefreshToken <String> -ClientId <String> -ClientSecret <String> [-GrantType <String>]
[-ProfileLocation <String>] [-Persist] [<CommonParameters>]
DESCRIPTION
This cmdlet refreshes a Google OAuth2 access token. The access token should have been retrieved through an
access code exchange and is refreshed with an associated refresh token. The refresh token can either be supplied
as a parameter or can be stored in a cached or persisted profile.
The updated token data is returned to pipeline regardless if the data is persisted or not. If the data is not
persisted,
the cache is still updated so the same session can access the new tokens.
PARAMETERS
-RefreshToken <String>
The refresh token returned during the initial authorization code exchange. This token is passed to the Google
OAuth
API to retrieve a new access token.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientId <String>
The client id associated with the refresh token or that indicates the stored profile to use that contains a
persisted
refresh token.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientSecret <String>
The client secret to pass with refresh request.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-GrantType <String>
The grant type for the refresh, this must be refresh_token, and is the only allowed, and default value, for
this
parameter.
Required? false
Position? named
Default value refresh_token
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? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Persist [<SwitchParameter>]
Specifies that the updated access token will be persisted to disk. If this is specified when RefreshToken and
ClientSecret
are specified, they are also persisted to disk.
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
System.Collections.Hashtable
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 1/27/2018
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Update-GoogleOAuth2Token -ClientId
"21251290794-21o6bku0cf8oln8pia505bk7813k838a.apps.googleusercontent.com" -Persist
This updates the access token for the specified cached or stored profile. The renewed access token is persisted to
disk. The
profile indicated by the client id must have a refresh_token and client_secret stored in the profile, otherwise an
exception
is thrown.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Update-GoogleOAuth2Token -ClientId
"21251290794-21o6bku0cf8oln8pia505bk7813k838a.apps.googleusercontent.com" `
-RefreshToken $RToken `
SYNOPSIS
Refreshes a Google OAuth2 access token that was retrieved with an authorization code.
SYNTAX
Update-GoogleOAuth2Token -ClientId <String> [-GrantType <String>] [-ProfileLocation <String>] [-Persist]
[<CommonParameters>]
Update-GoogleOAuth2Token -RefreshToken <String> -ClientId <String> -ClientSecret <String> [-GrantType <String>]
[-ProfileLocation <String>] [-Persist] [<CommonParameters>]
DESCRIPTION
This cmdlet refreshes a Google OAuth2 access token. The access token should have been retrieved through an
access code exchange and is refreshed with an associated refresh token. The refresh token can either be supplied
as a parameter or can be stored in a cached or persisted profile.
The updated token data is returned to pipeline regardless if the data is persisted or not. If the data is not
persisted,
the cache is still updated so the same session can access the new tokens.
PARAMETERS
-RefreshToken <String>
The refresh token returned during the initial authorization code exchange. This token is passed to the Google
OAuth
API to retrieve a new access token.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientId <String>
The client id associated with the refresh token or that indicates the stored profile to use that contains a
persisted
refresh token.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-ClientSecret <String>
The client secret to pass with refresh request.
Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-GrantType <String>
The grant type for the refresh, this must be refresh_token, and is the only allowed, and default value, for
this
parameter.
Required? false
Position? named
Default value refresh_token
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? named
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Persist [<SwitchParameter>]
Specifies that the updated access token will be persisted to disk. If this is specified when RefreshToken and
ClientSecret
are specified, they are also persisted to disk.
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
System.Collections.Hashtable
NOTES
AUTHOR: Michael Haken
LAST UPDATE: 1/27/2018
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Update-GoogleOAuth2Token -ClientId
"21251290794-21o6bku0cf8oln8pia505bk7813k838a.apps.googleusercontent.com" -Persist
This updates the access token for the specified cached or stored profile. The renewed access token is persisted to
disk. The
profile indicated by the client id must have a refresh_token and client_secret stored in the profile, otherwise an
exception
is thrown.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Update-GoogleOAuth2Token -ClientId
"21251290794-21o6bku0cf8oln8pia505bk7813k838a.apps.googleusercontent.com" `
-RefreshToken $RToken `