< Back

Test-IsGoogleOAuth2TokenExpired

Tue Jan 14, 2020 12:06 am

NAME Test-IsGoogleOAuth2TokenExpired



SYNOPSIS

Tests whether the provided token or token in a stored profile is expired.





SYNTAX

Test-IsGoogleOAuth2TokenExpired -AccessToken <String> [-ProfileLocation <String>] [-Buffer <Int32>]

[<CommonParameters>]



Test-IsGoogleOAuth2TokenExpired -ClientId <String> [-ProfileLocation <String>] [-Buffer <Int32>]

[<CommonParameters>]





DESCRIPTION

This cmdlet tests a provided access token or an access token stored in a client profile to

see whether it has expired.



The cmdlet will by default return true if the ClientId does not exist or does not contain an access_token

property. To throw

an exception in these cases use -ErrorAction Stop.





PARAMETERS

-AccessToken <String>

The token to test.



Required? true

Position? named

Default value [System.String]::Empty

Accept pipeline input? false

Accept wildcard characters? false



-ClientId <String>

The id of the profile containing the access token to test. If the client profile does not

contain an access token, this will return false, unless the ErrorActionPreference is set to

stop, in which case an exception is thrown.



Required? true

Position? named

Default value

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



-Buffer <Int32>

The number of seconds to buffer against the actual expiration. This defaults to 60, and can be between 1 and

60.



For example, if the buffer is set to 30, and the token expires in 25 seconds from now, the cmdlet would report

true for being expired. This helps ensure a token doesn't expire mid-request and isn't refreshed before being

used.



Required? false

Position? named

Default value 60

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/27/2018



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$Expired = Test-IsGoogleOAuth2TokenExpired -AccessToken $Token



Tests whether the token contained in the $Token variable is expired









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>try



{