本文整理汇总了Java中org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory类的典型用法代码示例。如果您正苦于以下问题:Java OAuthClientResponseFactory类的具体用法?Java OAuthClientResponseFactory怎么用?Java OAuthClientResponseFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OAuthClientResponseFactory类属于org.apache.oltu.oauth2.client.response包,在下文中一共展示了OAuthClientResponseFactory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory; //导入依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
String requestMethod, Class<T> responseClass)
throws OAuthSystemException, OAuthProblemException {
MediaType mediaType = MediaType.parse("application/json");
Request.Builder requestBuilder = new Request.Builder().url(request.getLocationUri());
if(headers != null) {
for (Entry<String, String> entry : headers.entrySet()) {
if (entry.getKey().equalsIgnoreCase("Content-Type")) {
mediaType = MediaType.parse(entry.getValue());
} else {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
}
}
RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
requestBuilder.method(requestMethod, body);
try {
Response response = client.newCall(requestBuilder.build()).execute();
return OAuthClientResponseFactory.createCustomResponse(
response.body().string(),
response.body().contentType().toString(),
response.code(),
responseClass);
} catch (IOException e) {
throw new OAuthSystemException(e);
}
}
开发者ID:ARMmbed,项目名称:mbed-cloud-sdk-java,代码行数:32,代码来源:OAuthOkHttpClient.java
示例2: execute
import org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory; //导入依赖的package包/类
public <T extends OAuthClientResponse> T execute(OAuthClientRequest request, Map<String, String> headers,
String requestMethod, Class<T> responseClass)
throws OAuthSystemException, OAuthProblemException {
MediaType mediaType = MediaType.parse("application/json");
Builder requestBuilder = new Builder().url(request.getLocationUri());
if(headers != null) {
for (Entry<String, String> entry : headers.entrySet()) {
if (entry.getKey().equalsIgnoreCase("Content-Type")) {
mediaType = MediaType.parse(entry.getValue());
} else {
requestBuilder.addHeader(entry.getKey(), entry.getValue());
}
}
}
RequestBody body = request.getBody() != null ? RequestBody.create(mediaType, request.getBody()) : null;
requestBuilder.method(requestMethod, body);
try {
Response response = client.newCall(requestBuilder.build()).execute();
return OAuthClientResponseFactory.createCustomResponse(
response.body().string(),
response.body().contentType().toString(),
response.code(),
responseClass);
} catch (IOException e) {
throw new OAuthSystemException(e);
}
}
开发者ID:hardsky,项目名称:lucky-calories,代码行数:32,代码来源:OAuthOkHttpClient.java
注:本文中的org.apache.oltu.oauth2.client.response.OAuthClientResponseFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论