1

我在开始创建谷歌应用市场应用程序时遇到了很多麻烦。

我尝试了很多演示,包括可以从谷歌下载的 php hello world 示例。在每种情况下,openid 部分都可以正常工作,但 oauth 失败了。

我已将其追溯到未返回 oauth 请求令牌的混合 openid/oauth 请求。您可以从 googlecodesamples 此处查看我的混合标准演示版本http://lookmumimontheinternet.com/staging/hybrid/index.php

您可以看到我正在停止重定向并在链接中输出 url 以进行调试。我还输出了 $_REQUEST 对象中返回的所有内容。

这与具有以下清单的市场应用程序相关联:

<?xml version="1.0" encoding="UTF-8" ?>
<ApplicationManifest xmlns="http://schemas.google.com/ApplicationManifest/2009">
  <!-- Metadata -->
  <Name>Hello World</Name>
  <Description>A simple application for demonstrating the marketplace</Description>
  <Support>
    <Link rel="support" href="http://www.lookmumimontheinternet.com/staging/hybrid/support.php" />
  </Support>

  <!-- Navigation link -->
  <Extension id="navlink" type="link">
    <Name>Hello World</Name>
    <Url>http://www.lookmumimontheinternet.com/staging/hybrid/index.php?from=google&amp;domain=${DOMAIN_NAME}</Url>
    <Scope ref="calendarFeed"/>
  </Extension>

  <!-- Single Sign On with OpenID -->
  <Extension id="realm" type="openIdRealm">
    <Url>http://lookmumimontheinternet.com/staging/hybrid</Url>
  </Extension>

  <!-- Authorized Data access -->
  <Scope id="calendarFeed">
    <Url>https://www.google.com/calendar/feeds/</Url>
    <Reason>This app displays your next upcoming calendar appointment..</Reason>
  </Scope>
</ApplicationManifest>

这是我安装演示的 php 配置(我知道我不应该发布秘密,但它只是一个测试应用程序):

$CONSUMER_KEY = '995079586589.apps.googleusercontent.com';
$CONSUMER_SECRET = '6yTp+2Xz7nSqB4Yx6OdSds7n';

$openid_params = array(
  'openid.ns'                => 'http://specs.openid.net/auth/2.0',
  'openid.claimed_id'        => 'http://specs.openid.net/auth/2.0/identifier_select',
  'openid.identity'          => 'http://specs.openid.net/auth/2.0/identifier_select',
  'openid.return_to'         => "http://lookmumimontheinternet.com/staging/hybrid/index.php",
  'openid.realm'             => "http://lookmumimontheinternet.com/staging/hybrid",
  'openid.mode'              => @$_REQUEST['openid_mode'],
  'openid.ns.ui'             => 'http://specs.openid.net/extensions/ui/1.0',
  'openid.ns.ext1'           => 'http://openid.net/srv/ax/1.0',
  'openid.ext1.mode'         => 'fetch_request',
  'openid.ext1.type.email'   => 'http://axschema.org/contact/email',
  'openid.ext1.type.first'   => 'http://axschema.org/namePerson/first',
  'openid.ext1.type.last'    => 'http://axschema.org/namePerson/last',
  'openid.ext1.type.country' => 'http://axschema.org/contact/country/home',
  'openid.ext1.type.lang'    => 'http://axschema.org/pref/language',
  'openid.ext1.required'     => 'email,first,last,country,lang',
  'openid.ns.oauth'          => 'http://specs.openid.net/extensions/oauth/1.0',
  'openid.oauth.consumer'    => $CONSUMER_KEY,
  'openid.oauth.scope'       => implode(' ', $scopes)
);

$openid_ext = array(
  'openid.ns.ext1'           => 'http://openid.net/srv/ax/1.0',
  'openid.ext1.mode'         => 'fetch_request',
  'openid.ext1.type.email'   => 'http://axschema.org/contact/email',
  'openid.ext1.type.first'   => 'http://axschema.org/namePerson/first',
  'openid.ext1.type.last'    => 'http://axschema.org/namePerson/last',
  'openid.ext1.type.country' => 'http://axschema.org/contact/country/home',
  'openid.ext1.type.lang'    => 'http://axschema.org/pref/language',
  'openid.ext1.required'     => 'email,first,last,country,lang',
  'openid.ns.oauth'          => 'http://specs.openid.net/extensions/oauth/1.0',
  'openid.oauth.consumer'    => $CONSUMER_KEY,
  'openid.oauth.scope'       => implode(' ', $scopes),
  'openid.ui.icon'           => 'true'
);

您可以在运行演示时看到即使正在请求它也没有返回 oauth 令牌(据我所知是正确的)。谁能看到我在这里做错了什么?

4

1 回答 1

1

好的解决了。由于应用程序在安装时已预先批准,因此您无需获得 oauth 访问权限。您的应用程序密钥已经拥有它。

于 2011-04-05T05:46:19.787 回答