Skip to content

Request access to Google drive option #6

Description

@dg-hub

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"

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions