Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request access to Google drive option #6

Open
dg-hub opened this issue Feb 28, 2022 · 0 comments
Open

Request access to Google drive option #6

dg-hub opened this issue Feb 28, 2022 · 0 comments

Comments

@dg-hub
Copy link

dg-hub commented Feb 28, 2022

Hi @AnalyticJeremy !

Thanks for your great work!

In order to Enable the "Request access to Google drive" option in the Google BigQuery Linked Service
as described here

An additional scope needs to be added to Authentication Request in 01 Get Code URL.ps1

The additional scope is:
https://www.googleapis.com/auth/drive

It is required when creating external tables to Google Sheets. I have implemented this by adding the following....

# 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.

$driveScopeEnabled = Read-Host " -- Include access to Google Drive y/n? [n]"

$clientId = ""
$clientSecret = ""
$redirectUrl = "http://127.0.0.1/"


# This is the access scope we will be requesting
$scope = "https://www.googleapis.com/auth/bigquery"
$driveScope = "https://www.googleapis.com/auth/drive"


# 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)
if($driveScopeEnabled.ToLower() -eq "y") {
   $authUrl += "+" + [uri]::EscapeDataString($driveScope)
}

$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"
@github-staff github-staff deleted a comment May 27, 2024
@github-staff github-staff deleted a comment May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant