5

I need to authenticate to an API using OAUTH2, however, it has to be made programmatically, no user typing stuff in a browser is permitted.

This seems like such a simple use case, but I haven't found anything online, the only thing close to it was this post, and the only answer is "yeah, you don't want to use a web browser, but what if you do?"... This doesn't help.

So, please, opening a web browser is not an option, I just want to know if Google provides any way to authenticate purely through code.

Thank you!

6
  • Although I'm not sure about the Google APIs you want to use and your final goal, for example, how about using Service account? When the Service account is used, the access token can be retrieved without using the browser. Ref But if this was also not the direction you want, I apologize. Commented Dec 12, 2019 at 23:14
  • Generally, client credential grant is for that oauth.net/2/grant-types/client-credentials or password grant oauth.net/2/grant-types/password if you need it on behalf of the user Commented Dec 13, 2019 at 0:32
  • What is your environment? Is this machine to machine or is a user involved? Commented Dec 13, 2019 at 10:03
  • @Tanaike I believe that actually solves my problem, I'll look into it, thanks! You can post your answer below so I can accept it Commented Dec 13, 2019 at 18:32
  • 1
    @Tanaike Yes, that's great, thanks! Commented Dec 15, 2019 at 16:13

1 Answer 1

1

In order to achieve your goal, I would like to propose to use the Service account. When the Service account is used, the access token can be retrieved without using the browser.

As the points for using the Service account, please check the following points.

  • The Service account is not your own Google account.
  • For example, as one of several situations, if you want to manage a file in your Google Drive using the Service account, please share the file with the Service account. By this, the Service account can access to the file in your Google Drive.

References:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.