OAuth2 - Authorize with no user interaction

前端 未结 2 830
迷失自我
迷失自我 2021-02-08 12:45

So I\'m trying to access my own data from an external app via their API. I only need access to my own data. Not trying to receive data from any of my users\' accounts,

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-08 13:10

    The Oauth 2 grant flow that you're describing is the Authorization Code Grant Flow, like the above answer says. And like they say, if you have the option of using one of the above two grants with that API, that's the easiest solution.

    However, if you don't, there's still a way to avoid "user interaction". It's unclear what you mean by "user interaction", but in the Authorization Code flow, that usually means logging into a web app that calls the API you are trying to authenticate into, and then consenting on the consent page. See https://dev.fitbit.com/docs/oauth2/#authorization-page for an example (I implemented OAuth 2 for Fitbit :)). You'll need to use an automated web browser like Selenium to click the consent button. Then you can capture the code in the response from /authorize and send the code to the accesstoken endpoint.

提交回复
热议问题