Get OAuth tokens programmatically

007_agent report abuse

Hi everybody! I'm building my web application and there is a need to use 3rd party API. This API uses the OAuth protocol. I have generated the client key and client secret for my application. After this, I was able to get an access token. But each day it becomes expired and I need to repeat the entire procedure of authorization from the very beginning. It is annoying and time-consuming. I would like to automate this process. Is there a way to perform authorization with OAuth programmatically, without interacting with the front end (user interface)?

Answers

oksifoxy report abuse

No, you need to authorize your application by clicking on the button on front-end. It's OAuth requirement.

Alex0406 report abuse

Wait, I think the OAuth requirement is to authorize the access just once (the first time). After this, you can use the refresh token to refresh the access token programmatically, without user intervention. You should look at the tokens that the API returns to you and find there the refresh token. If it is presented, then you definitely don't need to click on the button on front-end each time: just send the refresh request to the API directly from the code.

007_agent report abuse

Yes, I have the access token as well as a refresh token. Thank you very much!

mariOn report abuse

Actually, there are services that allow to get OAuth tokens even without the first-time authorization using the front-end. There is something like a sandbox, where you can generate tokens for your app for testing. But nothing can interfere you to use these tokens in your code. So, you don't need to build even a simple front-end for your app. Research the website of your API, maybe it supports such an approach.

007_agent report abuse

Thanks, @mariOn !

Add Answer

Need support?

Just drop us an email to ... Show more