Always “Have Offline Access” | Google OAuth 2

后端 未结 5 2167
忘掉有多难
忘掉有多难 2021-02-09 02:59

I am trying to get fetch user\'s profile using Google OAuth2 api. After user authentication, on the consent page, I am always asked for \"Have Offline Access\"

The URL i

相关标签:
5条回答
  • 2021-02-09 03:09

    Because you are redirecting back to http(s)://localhost:/. This makes sense because any app that requests redirection to localhost is obviously running locally.

    Redirect it to a public web address and it will not bother you.

    0 讨论(0)
  • 2021-02-09 03:11

    if you are using node js module 'everyauth' , you can override the googles default value by

    .authQueryParam({ access_type:'online', approval_prompt:'auto' })
    
    0 讨论(0)
  • 2021-02-09 03:12

    I had the same problem, and after googling for a long while, I found this link:

    "This app would like to: Have offline access" when access_type=online

    it suggests to remove 'localhost' in the redirect_uri, and it works for me.

    0 讨论(0)
  • 2021-02-09 03:14

    Looks like you have registered your client as a "Native Application" instead of a "Web Application". Native apps get a refresh token by default which is a long lived token, for which the Resource Owner gets a notification and a consent screen because of its inherent security implications. Change your client type to "Web Application" assuming that's what it is...

    0 讨论(0)
  • 2021-02-09 03:29

    There are two parameters which can cause this prompt:

    • access_type (if it is 'offline', get refresh token)
    • approval_prompt (if it is 'force')

    A reference about this can be found here.

    Try to change the approval_prompt parameter to 'auto' or add it to your request and check the access_type parameter to 'online' or add it to your request.

    0 讨论(0)
提交回复
热议问题