Where to keep your client_secret.json on windows machine?
up vote
0
down vote
favorite
I am working with OAuth, for logging into Gmail account and sending emails via python script.
I have downloaded client_secret.json file, The file is stored inside C:Usersanuj.masand (Home folder).
While running Python script I am getting following error:
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'client_secret.json', 'No such file or directory', 2)
I can see that the file is not available where the script needs it to be.
I have read clientsecrets.py file and got to know following code loads the file.
def _loadfile(filename):
try:
with open(filename, 'r') as fp:
obj = json.load(fp)
except IOError as exc:
raise InvalidClientSecretsError('Error opening file', exc.filename,
exc.strerror, exc.errno)
return _validate_clientsecrets(obj)
My code is jumping right into exception part.
My question is where to store client_secret.json file? so that interpreter can find the file and moves forward. Where does python really looks for this file?
Reference: Script
python-3.x oauth-2.0 gmail-api
add a comment |
up vote
0
down vote
favorite
I am working with OAuth, for logging into Gmail account and sending emails via python script.
I have downloaded client_secret.json file, The file is stored inside C:Usersanuj.masand (Home folder).
While running Python script I am getting following error:
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'client_secret.json', 'No such file or directory', 2)
I can see that the file is not available where the script needs it to be.
I have read clientsecrets.py file and got to know following code loads the file.
def _loadfile(filename):
try:
with open(filename, 'r') as fp:
obj = json.load(fp)
except IOError as exc:
raise InvalidClientSecretsError('Error opening file', exc.filename,
exc.strerror, exc.errno)
return _validate_clientsecrets(obj)
My code is jumping right into exception part.
My question is where to store client_secret.json file? so that interpreter can find the file and moves forward. Where does python really looks for this file?
Reference: Script
python-3.x oauth-2.0 gmail-api
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working with OAuth, for logging into Gmail account and sending emails via python script.
I have downloaded client_secret.json file, The file is stored inside C:Usersanuj.masand (Home folder).
While running Python script I am getting following error:
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'client_secret.json', 'No such file or directory', 2)
I can see that the file is not available where the script needs it to be.
I have read clientsecrets.py file and got to know following code loads the file.
def _loadfile(filename):
try:
with open(filename, 'r') as fp:
obj = json.load(fp)
except IOError as exc:
raise InvalidClientSecretsError('Error opening file', exc.filename,
exc.strerror, exc.errno)
return _validate_clientsecrets(obj)
My code is jumping right into exception part.
My question is where to store client_secret.json file? so that interpreter can find the file and moves forward. Where does python really looks for this file?
Reference: Script
python-3.x oauth-2.0 gmail-api
I am working with OAuth, for logging into Gmail account and sending emails via python script.
I have downloaded client_secret.json file, The file is stored inside C:Usersanuj.masand (Home folder).
While running Python script I am getting following error:
oauth2client.clientsecrets.InvalidClientSecretsError: ('Error opening file', 'client_secret.json', 'No such file or directory', 2)
I can see that the file is not available where the script needs it to be.
I have read clientsecrets.py file and got to know following code loads the file.
def _loadfile(filename):
try:
with open(filename, 'r') as fp:
obj = json.load(fp)
except IOError as exc:
raise InvalidClientSecretsError('Error opening file', exc.filename,
exc.strerror, exc.errno)
return _validate_clientsecrets(obj)
My code is jumping right into exception part.
My question is where to store client_secret.json file? so that interpreter can find the file and moves forward. Where does python really looks for this file?
Reference: Script
python-3.x oauth-2.0 gmail-api
python-3.x oauth-2.0 gmail-api
edited Nov 19 at 13:23
asked Nov 19 at 13:08
Anuj Masand
162113
162113
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
According to this quickstart guide, you are to move the downloaded file to your working directory. With the file named as credentials.json
, the guide implemented the file reading as:
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
Do ensure that the filenames completely match.
Thanks @jacque for reverting and for your time, i have figured it out. Instead of passing the file name i did pass the full path(where ever you save your file), it worked.Answer to my question is still away. Thanks anyway.
– Anuj Masand
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
According to this quickstart guide, you are to move the downloaded file to your working directory. With the file named as credentials.json
, the guide implemented the file reading as:
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
Do ensure that the filenames completely match.
Thanks @jacque for reverting and for your time, i have figured it out. Instead of passing the file name i did pass the full path(where ever you save your file), it worked.Answer to my question is still away. Thanks anyway.
– Anuj Masand
2 days ago
add a comment |
up vote
1
down vote
According to this quickstart guide, you are to move the downloaded file to your working directory. With the file named as credentials.json
, the guide implemented the file reading as:
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
Do ensure that the filenames completely match.
Thanks @jacque for reverting and for your time, i have figured it out. Instead of passing the file name i did pass the full path(where ever you save your file), it worked.Answer to my question is still away. Thanks anyway.
– Anuj Masand
2 days ago
add a comment |
up vote
1
down vote
up vote
1
down vote
According to this quickstart guide, you are to move the downloaded file to your working directory. With the file named as credentials.json
, the guide implemented the file reading as:
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
Do ensure that the filenames completely match.
According to this quickstart guide, you are to move the downloaded file to your working directory. With the file named as credentials.json
, the guide implemented the file reading as:
# The file token.json stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
store = file.Storage('token.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('credentials.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('gmail', 'v1', http=creds.authorize(Http()))
Do ensure that the filenames completely match.
answered Nov 20 at 9:10
Jacque
1594
1594
Thanks @jacque for reverting and for your time, i have figured it out. Instead of passing the file name i did pass the full path(where ever you save your file), it worked.Answer to my question is still away. Thanks anyway.
– Anuj Masand
2 days ago
add a comment |
Thanks @jacque for reverting and for your time, i have figured it out. Instead of passing the file name i did pass the full path(where ever you save your file), it worked.Answer to my question is still away. Thanks anyway.
– Anuj Masand
2 days ago
Thanks @jacque for reverting and for your time, i have figured it out. Instead of passing the file name i did pass the full path(where ever you save your file), it worked.Answer to my question is still away. Thanks anyway.
– Anuj Masand
2 days ago
Thanks @jacque for reverting and for your time, i have figured it out. Instead of passing the file name i did pass the full path(where ever you save your file), it worked.Answer to my question is still away. Thanks anyway.
– Anuj Masand
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375353%2fwhere-to-keep-your-client-secret-json-on-windows-machine%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown