Examples of AccessTokenResponse


Examples of com.google.api.client.auth.oauth2.draft10.AccessTokenResponse

    log.info("clientId=" + clientId + ", clientSecret=" + clientSecret + ", code=" + code
        + ", callbackUrl=" + callbackUrl);
    GoogleAuthorizationCodeGrant authRequest = new GoogleAuthorizationCodeGrant(
        new UrlFetchTransport(), new JacksonFactory(), clientId, clientSecret, code, callbackUrl);

    AccessTokenResponse authResponse;
    try {
      authResponse = authRequest.execute();
    } catch (IOException e) {
      log.log(Level.WARNING, "Failed attempt, trying again", e);
      if (e instanceof HttpResponseException) {
View Full Code Here

Examples of com.google.api.client.auth.oauth2.draft10.AccessTokenResponse

    logger.info("Oauth response code is: " + code);
    HttpTransport httpTransport = new NetHttpTransport();
    JacksonFactory jsonFactory = new JacksonFactory();
    ModelAndView mv = new ModelAndView();
    try {
      AccessTokenResponse googleResponse = new GoogleAuthorizationCodeGrant(
          httpTransport, jsonFactory, clientId, clientSecret, code,
          redirectUrl).execute();
      String accessToken = googleResponse.accessToken;
      String refreshToken = googleResponse.refreshToken;
View Full Code Here

Examples of com.google.api.client.auth.oauth2.draft10.AccessTokenResponse

    // Exchange for an access and refresh token
    GoogleAuthorizationCodeGrant authRequest = new GoogleAuthorizationCodeGrant(transport,
        factory, clientId, clientSecret, authorizationCode, AUTH_REDIRECT_URI);
    authRequest.useBasicAuthorization = false;
    AccessTokenResponse authResponse = authRequest.execute();

    accessToken = authResponse.accessToken;
    refreshToken = authResponse.refreshToken;

    GoogleAccessProtectedResource access = new GoogleAccessProtectedResource(accessToken, transport,
View Full Code Here

Examples of com.nimbusds.oauth2.sdk.AccessTokenResponse

   *                        OpenID Connect access token response.
   */
  public static OIDCAccessTokenResponse parse(final JSONObject jsonObject)
    throws ParseException {
   
    AccessTokenResponse atr = AccessTokenResponse.parse(jsonObject);
   
    JWT idToken = null;
   
    if (jsonObject.containsKey("id_token")) {
     
      try {
        idToken = JWTParser.parse(JSONObjectUtils.getString(jsonObject, "id_token"));
       
      } catch (java.text.ParseException e) {
     
        throw new ParseException("Couldn't parse ID token: " + e.getMessage(), e);
      }
    }

    // Parse the custom parameters
    Map<String,Object> customParams = new HashMap<>();
    customParams.putAll(atr.getCustomParams());
    customParams.remove("id_token");
   
    return new OIDCAccessTokenResponse(atr.getAccessToken(),
                                 atr.getRefreshToken(),
                                 idToken,
                                 customParams);
  }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse

      form.param("grant_type", "authorization_code")
              .param("code", code)
              .param("redirect_uri", redirectUri);

      Response res = realmInfo.getCodeUrl().request().header(HttpHeaders.AUTHORIZATION, authHeader).post(Entity.form(form));
      AccessTokenResponse tokenResponse;
      try
      {
         if (res.getStatus() != 200)
         {
            log.error("failed to turn code into token");
            sendError(Response.Status.FORBIDDEN.getStatusCode());
            return false;
         }
         log.debug("media type: " + res.getMediaType());
         log.debug("Content-Type header: " + res.getHeaderString("Content-Type"));
         tokenResponse = res.readEntity(AccessTokenResponse.class);
      }
      finally
      {
         res.close();
      }

      tokenString = tokenResponse.getToken();
      try
      {
         token = RSATokenVerifier.verifyToken(tokenString, realmInfo.getMetadata());
         log.debug("Verification succeeded!");
      }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse

         }
         else if (res.getStatus() != 200)
         {
            throw new InternalServerErrorException(new Exception("Unknown error when getting acess token"));
         }
         AccessTokenResponse tokenResponse = res.readEntity(AccessTokenResponse.class);
         return tokenResponse.getToken();
      }
      finally
      {
         res.close();
      }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse

            {
               codeRoles.remove(role);
            }
         }
      }
      AccessTokenResponse res = accessTokenResponse(realmPrivateKey, accessCode.getToken());
      response.setStatus(200);
      response.setContentType("application/json");
      accessTokenResponseWriter.writeValue(response.getOutputStream(), res);
      response.getOutputStream().flush();
   }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse

   protected AccessTokenResponse accessTokenResponse(PrivateKey privateKey, SkeletonKeyToken token)
   {
      String encodedToken = buildTokenString(privateKey, token);

      AccessTokenResponse res = new AccessTokenResponse();
      res.setToken(encodedToken);
      res.setTokenType("bearer");
      if (token.getExpiration() != 0)
      {
         long time = token.getExpiration() - (System.currentTimeMillis() / 1000);
         res.setExpiresIn(time);
      }
      return res;
   }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse

         return;
      }
      GenericPrincipal gp = basicAuth(request, response);
      if (gp == null) return;
      SkeletonKeyToken token = buildToken(gp);
      AccessTokenResponse res = accessTokenResponse(realmPrivateKey, token);
      response.setStatus(200);
      response.setContentType("application/json");
      accessTokenResponseWriter.writeValue(response.getOutputStream(), res);
      response.getOutputStream().flush();
   }
View Full Code Here

Examples of org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse

         Map<String, String> res = new HashMap<String, String>();
         res.put("error", "invalid_grant");
         res.put("error_description", "Auth error");
         return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON_TYPE).entity(res).build();
      }
      AccessTokenResponse res = accessTokenResponse(realm.getPrivateKey(), accessCode.getToken());
      return Response.ok(res).build();

   }
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.