I have a python script to consult certain data from Google Analytics but im trying to go a little bit further and let Lambda (from amazon web services) do it automatically for me everyday. But i encounter a problem and im stuck with it.
I don't know how can i authenticate OAuth 2.0 from the script without using a client_secrets.json file and if there is no other way to do it how and where i should leave the .json file in order to let it authenticate itself.
As it explains here since im not using one of google services i need to use:
from oauth2client.service_account import ServiceAccountCredentials
scopes = ['https://www.googleapis.com/auth/sqlservice.admin']
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'/path/to/keyfile.json', scopes)
but i have no path for the file.
If you check out the docs for
ServiceAccountCredentials
at https://oauth2client.readthedocs.io/en/latest/source/oauth2client.service_account.html#oauth2client.service_account.ServiceAccountCredentialsyou'll see that as well as
.from_json_keyfile_name
there is a constructorfrom_json(json_data)
. That should do what you need.