IT TIP

access_type = online 일 때“이 앱은 다음을 수행합니다. 오프라인 액세스 가능”

itqueen 2020. 12. 12. 12:55
반응형

access_type = online 일 때“이 앱은 다음을 수행합니다. 오프라인 액세스 가능”


OAuth 2.0 인증을 사용하는 Google 앱이 있습니다. 모든 것이 잘 작동했지만 최근에 다음과 같은 "권한 요청"화면이 표시되기 시작했습니다.

여기에 이미지 설명 입력

이상한 부분은 통과 할 때이 화면이 표시된다는 것 access_type=online입니다. 다시 말하지만 이것은 최근까지 작동했습니다.

이것의 원인은 무엇입니까? TIA

편집하다:

요청 된 범위는 다음과 같습니다.

https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/userinfo.profile

나는 이미 시도했다 :

  • 유무에 관계없이 access_type=online
  • 유무에 관계없이 approval_prompt=auto

편집 # 2 :

이것은 인증 URL을 생성하는 데 사용하는 파이썬 코드입니다.

encoded_params = urllib.urlencode({
    "response_type" : "code",
    "client_id" : MY_CLIENT_ID,
    "scope" : " ".join(MY_SCOPES),
    "redirect_uri" : MY_REDIRECT_URI,
    "state" : random_security_token,
    "access_type" : "online",
    "approval_prompt" : "auto",
    })

auth_url = "https://accounts.google.com/o/oauth2/auth?" + encoded_params

업데이트 (10 월 14 일) :

새 스코프를 사용해도 동의 화면이 표시됩니다. 최근에 인증에 사용하던 새 장치를 위해 가져 왔습니다.


앱이 토큰을 요청하고 해당 범위에 대해 사용자에 대한 유효한 액세스 또는 새로 고침 토큰이 여전히있을 때 G가이 작업을 수행한다고 생각합니다.

해결책은 다음 요청을 실행하여 토큰을 다 사용한 경우 (사용자 로그 아웃시 또는 사용자 인증 직후) 토큰을 취소하는 것입니다.

https://accounts.google.com/o/oauth2/revoke?token={token}

앱 자격 증명을 제공 할 필요가 없으며 토큰 만 URL 인수로 제공하면됩니다.

(문서는 https://developers.google.com/accounts/docs/OAuth2WebServer#tokenrevoke )

나는 똑같은 문제를 가지고 있었고 access_type또는 approval_prompt가치의 조합이 그것을 해결하는 것처럼 보이지 않았습니다 . 토큰을 취소하는 것이 트릭이었습니다.

저장하지 않는 한 앱에 대한 모든 미결 토큰을 취소하는 방법을 모르겠습니다. 자체 사용자 계정으로 테스트하려면 여기에서 앱의 기존 토큰을 수동으로 취소 할 수 있습니다.

https://security.google.com/settings/security/permissions

Google은 최근 이메일 범위를 변경했습니다. 당신은 교체해야

https://www.googleapis.com/auth/userinfo.email

와:

https://www.googleapis.com/auth/plus.profile.emails.read 

과:

https://www.googleapis.com/auth/plus.login

그러면 오프라인 액세스가 사라집니다.

또한보십시오:

https://developers.google.com/+/api/oauth#email

Warning: This scope is deprecated. Google will no longer support this scope after Sept. 1, 2014. For details, see Migrating to Google+ Sign-In.

This also changes the way the email address is received:

https://developers.google.com/+/api/auth-migration#email

Also keep in mind that you have to activate the Google+ API in your management console in order for this to work.


Using http://localhost in the redirect_url parameter of the OAuth request will cause the user to be asked to grant offline access the first time they authenticate after each login.


Tzach. In order to not prompt the consent screen after first login. You may need this to pass the value to the function :

$client->setApprovalPrompt ("auto");


I think this has been answered, but I can't find the link right now.

In a nutshell, Google recently made some changes around scopes in order to implement incremental scopes. Part of those changes is that if your app causes a auth prompt, yet the user has already authed, Google has to ask for something, so asks for offline access. Try setting

approval_prompt=auto

to avoid the prompt


I was having the same issue. Although I was not setting

access_type=online

However, according to my understanding, the default

access_type 

is

online 

From: https://developers.google.com/identity/protocols/OAuth2WebServer: "The default style of access is called online."

What solved this for me was to remove:

prompt=consent

There is still a consent form on the first go of course, just now it is not a consent form asking for offline access, which probably scares away some would-be users.

I believe the prompt parameter is intended as a replacement for the approval_prompt parameter. But it seems like if I set it to "consent", that should just mean I want the normal consent screen shown everytime, not the "offline access" consent screen. The docs here: https://developers.google.com/identity/protocols/OpenIDConnect#prompt don't seem to refute that notion, so I'm not sure why it behaves this way. But at least I was able to get it working the way I want it, for now.


Well, I don't know if this actually constitutes an answer, but I've found that some users see the:

'Have offline access'

compared to others (who get what I think you want to see):

'View basic information about your account'


Google API 클라이언트 라이브러리를 사용하고 있습니까?

https://developers.google.com/api-client-library/

자체적으로 토큰을 새로 고칠 때 access_type을 'offline'으로 설정합니다.

Python 버전에서는 oauth2client / client.py의 1204 행을 변경했습니다.

...에서

    'access_type': 'offline',

...에

    'access_type': 'online',

이제 제대로 작동합니다.


이 질문에 모든 것을 적용했습니다. 제 경우에는 쿠키 지우기 만 작동했습니다.

참고 URL : https://stackoverflow.com/questions/21405274/this-app-would-like-to-have-offline-access-when-access-type-online

반응형