Examples of TokenResponse


Examples of com.google.api.client.auth.oauth2.TokenResponse

            TokenErrorResponse json = new TokenErrorResponse();
            json.setError("invalid_client");
            responseData = json;
            response.setStatusCode(400);
          } else {
            TokenResponse json = new TokenResponse();
            json.setAccessToken(NEW_ACCESS_TOKEN);
            json.setRefreshToken(NEW_REFRESH_TOKEN);
            json.setExpiresInSeconds(EXPIRES_IN);
            responseData = json;
          }
          response.setContent(JSON_FACTORY.toString(responseData));
          return response;
        }
View Full Code Here

Examples of com.google.api.client.auth.oauth2.TokenResponse

      lock.lock();
      try {
        if (flow == null) {
          flow = initializeFlow();
        }
        TokenResponse response = flow.newTokenRequest(code).setRedirectUri(redirectUri).execute();
        String userId = getUserId(req);
        Credential credential = flow.createAndStoreCredential(response, userId);
        onSuccess(req, resp, credential);
      } finally {
        lock.unlock();
View Full Code Here

Examples of com.google.api.client.auth.oauth2.TokenResponse

    }

    private Analytics initializeAnalytics() {
        if (analytics == null) {
            GoogleAnalyticsProvider provider = new GoogleAnalyticsProvider();
            TokenResponse tokenResponse = new TokenResponse().setRefreshToken(getConnectionCredentials().getOauthRefreshToken());
            GoogleCredential credential = new GoogleCredential.Builder()
                    .setJsonFactory(jsonFactory)
                    .setTransport(transport)
                    .setClientSecrets(provider.getClientId(), provider.getClientSecret())
                    .build()
View Full Code Here

Examples of com.nimbusds.oauth2.sdk.TokenResponse

    OIDCAccessTokenResponse response = new OIDCAccessTokenResponse(accessToken, refreshToken, ID_TOKEN);

    HTTPResponse httpResponse = response.toHTTPResponse();

    TokenResponse tokenResponse = OIDCTokenResponseParser.parse(httpResponse);

    assertTrue(tokenResponse instanceof OIDCAccessTokenResponse);

    response = (OIDCAccessTokenResponse)tokenResponse;
View Full Code Here

Examples of com.nimbusds.oauth2.sdk.TokenResponse

    TokenErrorResponse response = new TokenErrorResponse(OAuth2Error.INVALID_GRANT);

    HTTPResponse httpResponse = response.toHTTPResponse();

    TokenResponse tokenResponse = OIDCTokenResponseParser.parse(httpResponse);

    assertTrue(tokenResponse instanceof TokenErrorResponse);

    response = (TokenErrorResponse)tokenResponse;
View Full Code Here

Examples of org.iplantc.agave.client.model.TokenResponse

  }
 
  private TokenResponse deserialize(String clientKey, String clientSecret, String response)
  throws ApiException
  {
    TokenResponse tokenResponse = new TokenResponse();
    try
    {
      JsonNode json = JsonUtil.getJsonMapper().readTree(response);
      if (json.has("access_token")) {
        tokenResponse.setStatus("success");
        tokenResponse.setMessage(null);
     
        int lifetime = 14400;
        int expiresIn = json.get("expires_in").asInt();
        DateTime created = new DateTime();
        created = created.minusSeconds(lifetime - expiresIn);
       
        AccessToken token = new AccessToken();
        token.setAccessToken(json.get("access_token").asText());
        token.setClientSecret(clientSecret);
        token.setClientKey(clientKey);
        token.setCreatedAt(created);
        token.setExpiresAt(new DateTime().plusSeconds(expiresIn));
        token.setRefreshToken(json.get("refresh_token").asText());
       
        tokenResponse.setResult(token);
      }
      else
      {
        tokenResponse.setStatus("error");
        tokenResponse.setMessage(null);
        tokenResponse.setResult(null);
      }
      return tokenResponse;
    } catch (Exception e) {
      throw new ApiException(500, e.getMessage());
    }
View Full Code Here

Examples of org.iplantc.agave.client.model.TokenResponse

  public void importCache()
  {
    try
    {
      TokenApi api = new TokenApi();
      TokenResponse response = api.createAuthToken(Settings.API_USERNAME, Settings.API_PASSWORD, Settings.API_CLIENT_KEY, Settings.API_CLIENT_SECRET);
      Assert.assertNotNull(response, "Null response from API");
      AccessToken token = response.getResult();
      Assert.assertNotNull(token, "Null token from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getAccessToken()), "Null access token string from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getRefreshToken()), "Null refresh token string from API");
      Assert.assertTrue(token.getCreatedAt().isBeforeNow(), "Token creation time was not in the past.");
      Assert.assertTrue(token.getExpiresAt().isAfterNow(), "Token creation time was not in the past.");
View Full Code Here

Examples of org.iplantc.agave.client.model.TokenResponse

  {
    if (Settings.AUTH_CACHE_FILE.exists()) {
      token = AccessToken.importCache(Settings.AUTH_CACHE_FILE);
    } else {
      TokenApi api = new TokenApi();
      TokenResponse response = api.createAuthToken(Settings.API_USERNAME, Settings.API_PASSWORD, Settings.API_CLIENT_KEY, Settings.API_CLIENT_SECRET);
      token = response.getResult();
      Assert.assertNotNull(token, "Null token from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getAccessToken()), "Null access token string from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getRefreshToken()), "Null refresh token string from API");
      Assert.assertTrue(token.getCreatedAt().isBeforeNow(), "Token creation time was not in the past.");
      Assert.assertTrue(token.getExpiresAt().isAfterNow(), "Token creation time was not in the past.");
View Full Code Here

Examples of org.iplantc.agave.client.model.TokenResponse

  @Test
  public void createAuthToken() {
    try {
      TokenApi api = new TokenApi();
      TokenResponse response = api.createAuthToken(Settings.API_USERNAME, Settings.API_PASSWORD, Settings.API_CLIENT_KEY, Settings.API_CLIENT_SECRET);
      Assert.assertNotNull(response, "Null response from API");
      AccessToken token = response.getResult();
      Assert.assertNotNull(token, "Null token from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getAccessToken()), "Null access token string from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getRefreshToken()), "Null refresh token string from API");
      Assert.assertTrue(token.getCreatedAt().isBeforeNow(), "Token creation time was not in the past.");
      Assert.assertTrue(token.getExpiresAt().isAfterNow(), "Token creation time was not in the past.");
View Full Code Here

Examples of org.iplantc.agave.client.model.TokenResponse

  @Test(dependsOnMethods={"createAuthToken"})
  public void refreshAuthToken()
  {
    try {
      TokenApi api = new TokenApi();
      TokenResponse response = api.createAuthToken(Settings.API_USERNAME, Settings.API_PASSWORD, Settings.API_CLIENT_KEY, Settings.API_CLIENT_SECRET);
      Assert.assertNotNull(response, "Null response from API");
      AccessToken token = response.getResult();
      Assert.assertNotNull(token, "Null token from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getAccessToken()), "Null access token string from API");
      Assert.assertFalse(StringUtils.isEmpty(token.getRefreshToken()), "Null refresh token string from API");
      Assert.assertTrue(token.getCreatedAt().isBeforeNow(), "Token creation time was not in the past.");
      Assert.assertTrue(token.getExpiresAt().isAfterNow(), "Token creation time was not in the past.");
     
      TokenResponse refreshResponse = api.refreshAuthToken(Settings.API_CLIENT_KEY, Settings.API_CLIENT_SECRET, token.getRefreshToken());
      AccessToken refreshToken = refreshResponse.getResult();
      Assert.assertNotNull(refreshToken, "Null refresh token from API");
      Assert.assertFalse(StringUtils.isEmpty(refreshToken.getAccessToken()), "Null refresh access token string from API");
      Assert.assertFalse(StringUtils.isEmpty(refreshToken.getRefreshToken()), "Null refresh refresh token string from API");
      Assert.assertTrue(refreshToken.getCreatedAt().isBefore(new DateTime().minusSeconds(2)), "Refresh token creation time was not in the past.");
      Assert.assertTrue(refreshToken.getExpiresAt().isAfterNow(), "Refresh token expiration time was not in the future.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.