Forums

How do I store a file created by the Flask app to the directory?

I am using Gmail APIs in flask. I need to create a token file to gain access.

store = file.Storage('/home/username/projectname/token.json')

However, it did not store anything to my directory. Is there any approach that I could make it possible? Thanks.

what is file.Storage?

if you are trying to create a file on your directory, wouldn't you just do a

with open('/home/username/projectname/token.json') as f:
    f.write('your token content')

Thanks for your reply.

The "file.Storage" is imported from oauth2client. I am not able to know the content of token until it is created.

perhaps u should read the google oauth2 docs to figure out how to use file.Storage then.