Package com.google.walkaround.wave.server.auth

Examples of com.google.walkaround.wave.server.auth.OAuthCredentials


    log.info("code=" + code + ", state=" + state);
    String[] split = state.split(" ");
    if (split.length != 2) {
      throw new BadRequestException("state格式错误: " + state);
    }
    OAuthCredentials credentials;
    try {
      credentials = oAuthProviderHelp.exchangeCodeForToken(split[0], code);
    } catch (IOException e) {
      log.log(Level.WARNING, "Failed attempt, trying again", e);
      if (e instanceof HttpResponseException) {
View Full Code Here


    JSONObject toRtn = new JSONObject();
    if (record != null) {
      try {
        StableUserId userId = record.getUserId();
        ParticipantId participantId = record.getParticipantId();
        OAuthCredentials oAuthCredentials = record.getOAuthCredentials();
        userContext.setUserId(userId);
        userContext.setParticipantId(participantId);
        userContext.setOAuthCredentials(oAuthCredentials);

        toRtn.put(TokenBasedAccountLookup.USER_ID_KEY, userId.getId());
        toRtn.put("participantId", participantId.getAddress());
        toRtn.put("access_token", xsrfHelper.get().createToken(oAuthCredentials.getAccessToken()));
      } catch (JSONException e) {
        throw new RuntimeException("Bad JSON: " + toRtn, e);
      }
    }
    resp.setStatus(200);
View Full Code Here

    @Inject Provider<HttpRequestBuilder> postRequest;

    public OAuthCredentials exchangeCodeForToken(String providerName, String authorizationCode)
        throws IOException {
      Pair<String, String> pair = exchangeCodeForToken(providerName, authorizationCode, false);
      OAuthCredentials credentials =
          new OAuthCredentials(pair.second == null ? "" : pair.second, pair.first);
      return credentials;
    }
View Full Code Here

  }

  @Override
  public void refreshToken() throws IOException {

    OAuthCredentials oldCredentials = getCredentials();

    String refreshToken = oldCredentials.getRefreshToken();
    if (refreshToken == null || refreshToken.isEmpty()) {
      return;
    }
    String newAccessToken =
        oAuthProvider.refreshToken(userContext.getOAuthProvider().getProviderName(), refreshToken);

    log.info("New access token: " + newAccessToken);
    userContext.setOAuthCredentials(new OAuthCredentials(refreshToken, newAccessToken));
    log.info("Successfully refreshed token: " + userContext);
  }
View Full Code Here

TOP

Related Classes of com.google.walkaround.wave.server.auth.OAuthCredentials

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.