Skip to content

Getting an exception while using authorize() method #605

@nirajsp47

Description

@nirajsp47

Hi, I am getting a Refresh error exception when I try to execute the authorize() method.

  raise exceptions.RefreshError(
google.auth.exceptions.RefreshError: ('invalid_client: Unauthorized', {'error': 'invalid_client', 'error_description': 'Unauthorized'

I am passing the "client_secret.json" file as a parameter :

gc = pygsheets.authorize(client_secret="client_secret.json")

Surprisingly, when I use the same json file renamed as "credentials.json" in basic example provided by ghseets, I dont see any issue.

 if not creds or not creds.valid:
    if creds and creds.expired and creds.refresh_token:
      creds.refresh(Request())
    else:
      flow = InstalledAppFlow.from_client_secrets_file(
          "credentials.json", SCOPES
      ) 

My json file is in this format :


{"installed":
   {
   "client_id":"",
   "project_id":"",
   "auth_uri":"https://accounts.google.com/o/oauth2/auth",
   "token_uri":"https://oauth2.googleapis.com/token",
   "auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
   "client_secret":"",
   "redirect_uris":
   }
}

Can you please help to understand what am I missing?
Is there a possibility that the json file format from google has changed?

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