本文整理了Java中org.crazyyak.dev.jackson.YakJacksonObjectMapper
类的一些代码示例,展示了YakJacksonObjectMapper
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YakJacksonObjectMapper
类的具体详情如下:
包路径:org.crazyyak.dev.jackson.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;
}
内容来源于网络,如有侵权,请联系作者删除!