【问题标题】:GDK Authentication Process of Google Glass谷歌眼镜的GDK认证流程
【发布时间】:2014-10-21 08:58:49
【问题描述】:

在使用 GDK 的 Google Glass 应用程序中

GDK认证流程

  1. 当用户在 MyGlass 中打开您的 Glassware 时,他们会被重定向到您的身份验证 URL。这些请求包含一个名为 userToken 的查询参数,您稍后需要使用该参数。

没有获得 UserToken

警告:不要存储此用户令牌。它仅供 Google 的身份验证端点使用,仅在该会话期间将请求映射回原始用户,并且不包含任何可用于持久识别用户的信息。如果用户多次使用相同的 Glassware 进行身份验证,或者用户使用来自同一开发人员的不同 Glassware 进行身份验证,则不保证令牌相同。 用户在您的身份验证页面上输入他们的凭据。

  1. 您的服务器验证用户的凭据。如果凭证有效,请对 mirror.accounts.insert 方法进行 Mirror API 调用。此方法要求您在构建镜像服务对象时指定https://www.googleapis.com/auth/glass.thirdpartyauth 范围。帐户创建示例中显示了使用原始 HTTP 或 Java 进行此 API 调用的示例。

使用第三方服务器身份验证 在从 Mirror API 创建帐户时

我应该从哪里得到参数?像 1. 用户令牌 2.AuthType 3. 认证令牌 4. 账户名

我应该发送什么参数?

 /**
  * Creates an account and causes it to be synched up with the user's Glass.
  * This example only supports one auth token; modify it if you need to add
 * more than one, or to add features or user data or the password field.
 *
 * @param mirror the service returned by getMirrorService()
 * @param userToken the user token sent to your auth callback URL
  * @param accountName the account name for this particular user
  * @param authTokenType the type of the auth token (chosen by you)
  * @param authToken the auth token
  */
 public static void createAccount(Mirror mirror, String userToken, String accountName,
    String authTokenType, String authToken) {
    try {
     Account account = new Account();
     List<AuthToken> authTokens = Lists.newArrayList(
        new AuthToken().setType(authTokenType).setAuthToken(authToken));
     account.setAuthTokens(authTokens);
     mirror.accounts().insert(
        userToken, ACCOUNT_TYPE, accountName, account).execute();
      } catch (IOException e) {
        e.printStackTrace();
     }

请帮帮我...

【问题讨论】:

    标签: google-glass google-mirror-api


    【解决方案1】:

    这里是参数来源:

    • 当用户单击身份验证 URL 时,您从 MyGlass 获得的 userToken:如果您没有得到它,请让审核团队知道,以便他们可以修复后端中缺少的任何内容。确保指定您要使用 GDK 身份验证。
    • accountName 由您决定:这是您要插入的用户帐户的名称。
    • authTokenType 也取决于您,但需要与您提供给审核团队的内容完全匹配。
    • authToken 是您的服务生成的令牌:同样,这是您为用户插入的令牌。

    【讨论】:

    • 能否请您详细指定authTokenType 和authToken,或者您可以给我们举个例子来说明这两个参数。
    • 例如authTokenTypecom.example.token,这完全取决于您的应用程序(例如,谷歌authTokenTypecom.google)。 authToken 是您的应用程序生成的令牌,我无法为您提供真实的示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多