Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

GMAIL API: I cant change account in python

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading