org.crazyyak.dev.jackson.YakJacksonObjectMapper类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(3.0k)|赞(0)|评价(0)|浏览(97)

本文整理了Java中org.crazyyak.dev.jackson.YakJacksonObjectMapper类的一些代码示例,展示了YakJacksonObjectMapper类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YakJacksonObjectMapper类的具体详情如下:
包路径:org.crazyyak.dev.jackson.YakJacksonObjectMapper
类名称:YakJacksonObjectMapper

YakJacksonObjectMapper介绍

暂无

代码示例

代码示例来源:origin: org.crazyyak.lib/yak-lib-spring-security

public static UserInfo getUserInfo(GoogleAuthentication authentication) throws IOException {
 Client client = ClientBuilder.newBuilder().build();
 UriBuilder uriBuilder = UriBuilder.fromUri("https://www.googleapis.com/oauth2/v1/userinfo");
 uriBuilder.queryParam("alt", "json");
 uriBuilder.queryParam("access_token", authentication.getAccessToken());
 Response response = client.target(uriBuilder).request(MediaType.APPLICATION_JSON_TYPE).get();
 String json = response.readEntity(String.class);
 return new YakJacksonObjectMapper().readValue(json, UserInfo.class);
}

代码示例来源:origin: org.crazyyak.dev/yak-dev-web-apis

public static UserInfo getUserInfo(String accessToken) throws IOException {
  Client client = ClientBuilder.newBuilder().build();
  UriBuilder uriBuilder = new JerseyUriBuilder().uri("https://www.googleapis.com/oauth2/v1/userinfo");
  uriBuilder.queryParam("alt", "json");
  uriBuilder.queryParam("access_token", accessToken);

  Response response = client.target(uriBuilder).request(MediaType.APPLICATION_JSON_TYPE).get();
  String json = response.readEntity(String.class);
  return new YakJacksonObjectMapper().readValue(json, UserInfo.class);
 }
}

代码示例来源:origin: org.crazyyak.lib/yak-lib-spring-security

String json = jerseyResponse.readEntity(String.class);
YakJacksonObjectMapper objectMapper = new YakJacksonObjectMapper();
GoogleAuthentication googleAuth = objectMapper.readValue(json, GoogleAuthentication.class);

代码示例来源:origin: org.crazyyak.dev/yak-dev-web-apis

public static GoogleAuthentication getAuthResponse(String code, String clientId, String clientSecret) throws IOException {
 Client client = ClientBuilder.newBuilder().build();
 Form form = new Form();
 form.param("code", code);
 form.param("client_id", clientId);
 form.param("client_secret", clientSecret);
 form.param("grant_type", "authorization_code");
 form.param("redirect_uri", "postmessage");
 UriBuilder uriBuilder = new JerseyUriBuilder().uri("https://accounts.google.com/o/oauth2/token");
 Response jerseyResponse = client.target(uriBuilder)
   .request(MediaType.APPLICATION_JSON_TYPE)
   .post(Entity.entity(form,MediaType.APPLICATION_FORM_URLENCODED_TYPE));
 int status = jerseyResponse.getStatus();
 String json = jerseyResponse.readEntity(String.class);
 YakJacksonObjectMapper objectMapper = new YakJacksonObjectMapper();
 GoogleAuthentication googleAuth = objectMapper.readValue(json, GoogleAuthentication.class);
 // If there was an error in the token info, abort.
 if (StringUtils.isNotBlank(googleAuth.getError())) {
  String msg = String.format("Authentication Error: %s", googleAuth.getError());
  throw ApiException.internalServerError(msg);
 }
 return googleAuth;
}

相关文章

YakJacksonObjectMapper类方法