-
Notifications
You must be signed in to change notification settings - Fork 8
/
01 Get Code URL.ps1
30 lines (23 loc) · 1.29 KB
/
01 Get Code URL.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# A PowerShell script for getting an OAuth code URL from Google
# (This is Step 1 of a two-step process)
# written by Jeremy Peach (AnalyticJeremy)
# full documentation: https://github.com/AnalyticJeremy/ADF_BigQuery
# Before running this script, you need to set these three values. They can be
# obtained from the GCP console.
$clientId = "<your client Id>"
$clientSecret = "<your client secret>"
$redirectUrl = "<EXACT URL you entered when creating your OAuth credentials>"
# This is the access scope we will be requesting
$scope = "https://www.googleapis.com/auth/bigquery"
# Build the URL for Google's OAuth service
$authUrl = "https://accounts.google.com/o/oauth2/v2/auth"
$authUrl += "?client_id=" + $clientId
$authUrl += "&redirect_uri=" + [uri]::EscapeDataString($redirectUrl)
$authUrl += "&scope=" + [uri]::EscapeDataString($scope)
$authUrl += "&access_type=offline&include_granted_scopes=true&response_type=code&prompt=consent"
Write-Host "`n`n$("*" * 80) `n"
Write-Host "Open the follwing URL in your web browser:`n"
Write-Host "`t$authUrl`n"
Write-Host "Log into Google and grant consent to the application. After clicking allow, you will be redirected to a URL."
Write-Host "Copy the URL to which you are redirected and proceed to Step 2."
Write-Host "`n$("*" * 80) `n`n"