GMAIL API: I cant change account in python

Question:

I want to change the account in python, but when I change

flow=InstalledAppFlow.from_client_secrets_file('onerandomclient.json', SCOPES)

For the other JSON, still connecting with the last account, not the one I put.

Asked By: GundamUser

||

Answers:

I am going to assume that you are following python quickstart

This sample stores the users credentials in token.json file

if os.path.exists('token.json'):
        creds = Credentials.from_authorized_user_file('token.json', SCOPES)

The code you are the code you are revering to simply identifies the application it is not associated with the user authencation the application. ‘credentials.json’ is the file downloaded from google developer console.

flow = InstalledAppFlow.from_client_secrets_file(
                'credentials.json', SCOPES)

So the solution to your issue is to delete ‘token.json’ and then your application should request authorization of the user again.

Answered By: DaImTo