dqoeghe9452 2014-02-03 12:08
浏览 137
已采纳

Google PHP API(google-api-php-client) - 始终提示进行离线访问访问

I have a very basic PHP site that I want to use oauth2 authentication against Google Apps, using the example they provided (below is my version), The user on authentication keeps getting prompted to allow my app offline access to their account, Which I don't want.

$this->gapps_api_client = new Google_Client();
// $this->gapps_api_client->setAccessType('online');
$this->gapps_api_client->setApplicationName( GAPPS_APPLICATION_NAME );
$this->gapps_api_client->setClientId( GAPPS_CLIENT_ID );
$this->gapps_api_client->setClientSecret( GAPPS_CLIENT_SECRET );
$this->gapps_api_client->setRedirectUri( GAPPS_REDIRECT_URI );

$this->oauth2 = new Google_Oauth2Service($this->gapps_api_client);

It's worth nothing I have been playing with "setAccessType" however no values seem to have an effect on this offline permission mode. I've tried leaving it commented out, setting it to "online", "offline" nothing has made a difference.

Anybody else been able to oauth2 authenticate without the user granting your app "Offline access"?

  • 写回答

1条回答 默认 最新

  • duai3681 2014-02-03 14:27
    关注

    The offline access display is often flagged if you have previously granted an app access, but the app is asking for sign in again (if the consent dialog is being forced or similar). This is due to incremental auth - its trying to hide previously granted scopes.

    To test this, try revoking all app access with https://security.google.com/settings/security/permissions and signing in again. You should see the full scopes.

    If that is the issue, then it is likely something your users wont see - when they sign in again they should not see a consent dialog unless you are using prompt=force or similar.

    You might also want to look at retrieving profile using the Google+ API (this works for all account types): https://developers.google.com/+/api/latest/people/get, and upgrading to the latest version of the PHP library: https://github.com/google/google-api-php-client

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 MIT控制器能控制不稳定系统吗
  • ¥15 公司代码X对业务伙伴X无效,处理方法?
  • ¥15 微信内链接跳转到浏览器打开怎么实现
  • ¥15 三角波可以直接加施密特电路整形到矩形波吗实物
  • ¥15 html,php,在使用html请求php文件时发生了错误,无法请求到php文件读取数据库并用javascript进行数据显示,刷新
  • ¥15 touchsocket udp组播
  • ¥20 MAC怎么安装Silverlight 插件?以及安装了怎么启用
  • ¥15 VS2012中查询语句无法填入解析,数值传不进去
  • ¥15 gis系统开发出现命名空间“ESRI.ArcGIS”中不存在类型或命名空间名“Analyst3D”报错
  • ¥15 怎么让ai定时给我发信息 c#或者python