简体   繁体   中英

The App keeps asking for permission to “Have offline access”, why?

After having authorized the app with oAuth2 and acquiring permissions for requested scopes, I still get a screen asking if I grant the app permission to Have offline access , each time I try to login with Google oAuth2. Isn't it something that shouldn't appear again, once I grant it permission to have it?

在此处输入图片说明

This prompt could come because of two parameters,

  • access_type (if it is 'offline')
  • approval_prompt (if it is 'force')

make sure you have set access_type to 'online' and apporoval_prompt to 'auto'

 $client->setAccessType('online');
 $client->setApprovalPrompt('auto') ;

Do you use the approval_prompt parameter? Try not to ask for offline access again if you already have an refresh token. It should stay valid even if the user logs in again, without requesting offline access.

A reference about this can be found here .

My guess is that your app has approval_prompt=force to force the OAuth each time. Since the user has already authorised whatever scopes you requested, there is no need to repeat them. However the screen has to say something, so in the absence of any better ideas, Google requests 'offline access".

Just make sure that you are not forcing auth and you should be fine.

This is not an error. This is the normal scenario of google oauth2.

First Process consent as follows:

  1. User consents to the application getting information about the user.
  2. When user clicks Accept button, browser will save consent info into cookie and google account will save permission (please view https://security.google.com/settings/security/permissions )

From Second Process:

Browser checks cookie consent permisson of google account.

  • If cookie exists in browser and has permission for this application ( https://security.google.com/settings/security/permissions ): consent screen will be ignored
  • If cookie exists in browser but does not have permission for this application: consent screen will be displayed
  • If cookie does not exist in browser: application will display 'Have offline access'.

Most probably this is very normal according to the incremental auth mechanism and its design, The idea is if a user has already granted the permissions to an app, there is no need to show the same permissions and ask the user to approve.

http://googleplusplatform.blogspot.com/2013/12/google-sign-in-improvements11.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM