Search code examples
gogoogle-drive-apigoogle-oauthgoogle-developers-console

Drive API App OAuth Permissions Not Updating


I am working on a Golang service that will connect to Google Drive and download a file. The issue is that no matter how I update the projects permissions, when I run application and go to the browser window to OAuth, it only shows the metadata permissions needing granted when have granted more so that I can download files.

Here are the steps I've taken for the service:

  1. I have created a project in Google Developer Console.

  2. In that project I have enabled and updated Google Drive permissions to the capture all auth/drive permission (I have also tried granting all and only some granular).

  3. I create the Golang service from this example: https://developers.google.com/drive/api/v3/quickstart/go

  4. I run the Golang app which prompts me to open a URL in browser to OAuth authenticate.

  5. I open link in browser, auth with my app-owner gmail account and every single time no matter what I do this is the only OAuth scope that shows:

enter image description here

If I use the Drive API Explorer to perform the file download it shows that I need these permissions:

enter image description here

When i click "Execute" in the explorer the OAuth popup shows all the permissions I would expect for my app and works correctly:

enter image description here

What am I doing wrong or missing?

Could this be because the app is an "internal" app?


Solution

  • The issue was in the Golang Quick-Start boilerplate code that I used to scaffold the application.

    This line was overriding the permission settings I was explicitly setting in console.

        // If modifying these scopes, delete your previously saved token.json.
        config, err := google.ConfigFromJSON(b, drive.DriveMetadataReadonlyScope)
        if err != nil {
            log.Fatalf("Unable to parse client secret file to config: %v", err)
        }
    

    fixed when changed to:

        // If modifying these scopes, delete your previously saved token.json.
        config, err := google.ConfigFromJSON(b, drive.DriveScope)
        if err != nil {
            log.Fatalf("Unable to parse client secret file to config: %v", err)
        }