Examples.ps1
## Getting the user access Token # The first 4 variables you'll get from https://console.developers.google.com/apis/dashboard after creating a project $projectID = "";$app_key = "" $app_Secret = "";$redirectURI = "" $scope = "https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file" $tokens = Get-GOAuthTokenUser -projectID $projectID -appKey $app_key -appSecret $app_secret -scope $scope -redirectUri $redirectURI -refreshToken $tokens.refreshToken $accessToken = $tokens.accesstoken ## Service token $scope = "https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file" $certPath = "<path to .p12 certificate file" $iss = '' #this is the service account eamil it will look like <something>@<projectname>.iam.gserviceaccount.com $certPswd = '' #Password for certificate $accessToken = Get-GOAuthTokenService -scope $scope -certPath $certPath -certPswd $certPswd -iss $iss # Tokens are good for 1 hour after that rerun $accessToken = Get-GOAuthTokenService -scope $scope -certPath $certPath -certPswd $certPswd -iss $iss # or $tokens = Get-GOAuthTokenUser -projectID $projectID -appKey $app_key -appSecret $app_secret -scope $scope -redirectUri $redirectURI -refreshToken $tokens.refreshToken # $accessToken = $tokens.accesstoken # depending on which one you used. # SIG # Begin signature block # MIIVSwYJKoZIhvcNAQcCoIIVPDCCFTgCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUN3Z124vO9wV4Ow+i7jUmsRDr # M3GgghA8MIIEmTCCA4GgAwIBAgIPFojwOSVeY45pFDkH5jMLMA0GCSqGSIb3DQEB # BQUAMIGVMQswCQYDVQQGEwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQg # TGFrZSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNV # BAsTGGh0dHA6Ly93d3cudXNlcnRydXN0LmNvbTEd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