【发布时间】:2014-10-21 08:58:49
【问题描述】:
在使用 GDK 的 Google Glass 应用程序中
GDK认证流程
- 当用户在 MyGlass 中打开您的 Glassware 时,他们会被重定向到您的身份验证 URL。这些请求包含一个名为 userToken 的查询参数,您稍后需要使用该参数。
没有获得 UserToken
警告:不要存储此用户令牌。它仅供 Google 的身份验证端点使用,仅在该会话期间将请求映射回原始用户,并且不包含任何可用于持久识别用户的信息。如果用户多次使用相同的 Glassware 进行身份验证,或者用户使用来自同一开发人员的不同 Glassware 进行身份验证,则不保证令牌相同。 用户在您的身份验证页面上输入他们的凭据。
- 您的服务器验证用户的凭据。如果凭证有效,请对 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