Google API客户端 - 了解代码

时间:2013-07-12 17:53:12

标签: java google-api-java-client

我正在研究Google API客户端的代码,以便能够为Google群组中的用户提供服务,但我在代码中有两个问题。

实施例

  /**
   * Exchange an authorization code for OAuth 2.0 credentials.
   *
   * @param authorizationCode Authorization code to exchange for OAuth 2.0
   *        credentials.
   * @return OAuth 2.0 credentials.
   * @throws CodeExchangeException An error occurred.
   */
  static Credential exchangeCode(String authorizationCode)
      throws CodeExchangeException {
    try {
      GoogleAuthorizationCodeFlow flow = getFlow();
      GoogleTokenResponse response =
          flow.newTokenRequest(authorizationCode).setRedirectUri(REDIRECT_URI).execute();
      return flow.createAndStoreCredential(response, null);
    } catch (IOException e) {
      System.err.println("An error occurred: " + e);
      throw new CodeExchangeException(null);
    }
  }

该代码段显示:

flow.createAndStoreCredential (response, null);
  1. 它究竟做了什么?存储在数据库或内存中? 什么是数据库?
  2. 其中null为parametro,可以传递给userId。如何将此用户标识作为参数传递?
  3. 来源:https://developers.google.com/drive/training/drive-apps/auth/credentials

0 个答案:

没有答案