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










share|improve this question




























    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










    share|improve this question


























      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










      share|improve this question















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 at 13:23

























      asked Nov 19 at 13:08









      Anuj Masand

      162113




      162113
























          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.






          share|improve this answer





















          • 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













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          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

























          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.






          share|improve this answer





















          • 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

















          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.






          share|improve this answer





















          • 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















          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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




















          • 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




















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          To store a contact into the json file from server.js file using a class in NodeJS

          Redirect URL with Chrome Remote Debugging Android Devices

          Dieringhausen