Authenticating with OAuth2 for an app *and* a website

前端 未结 6 608
予麋鹿
予麋鹿 2020-12-02 04:10

I\'m developing a website that is primarily accessed via an app, and I want to use OAuth2 for user registration and authentication. Since it is an Android app I will start u

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 04:38

    I just posted an answer to a similar StackOverflow question.

    Google calls this Hybrid Apps and explains how an "Android app obtains offline access for Web back-end".

    The gist of it is that you'll have to pass a massaged scope string into GoogleAuthUtil.getToken in order to get it to return an Authorization Code (not an OAuth2 Token). That Authorization Code can be passed from your mobile app to your server and be exchanged for an OAuth2 Token and Refresh Token, according to this schematic.

    The scope parameter needs to look something like this:

    oauth2:server:client_id::api_scope:  ...
    

提交回复
热议问题