本文整理了Java中com.google.api.client.http.HttpRequest.addParser()
方法的一些代码示例,展示了HttpRequest.addParser()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.addParser()
方法的具体详情如下:
包路径:com.google.api.client.http.HttpRequest
类名称:HttpRequest
方法名:addParser
暂无
代码示例来源:origin: stackoverflow.com
private ApiClient createClientForAccessToken(
final JsonHttpParser parser, HttpTransport transport, final String accessToken) {
final AccessProtectedResource accessProtectedResource =
new GoogleAccessProtectedResource(accessToken);
HttpRequestInitializer transportInitializer = new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
request.addParser(parser);
request.setConnectTimeout(CONNECTION_TIMEOUT_MILLIS);
request.setReadTimeout(SOCKET_TIMEOUT_MILLIS);
request.setEnableGZipContent(true);
request.setNumberOfRetries(0);
accessProtectedResource.initialize(request);
}
};
return new AdsenseApiClient(transport, parser.getJsonFactory(), transportInitializer);
}
代码示例来源:origin: com.google.api.client/google-api-client-googleapis
/**
* Retries the token information as described in <a href=
* "http://code.google.com/apis/accounts/docs/AuthSub.html#AuthSubTokenInfo"
* >AuthSubTokenInfo</a>.
*
* @throws HttpResponseException if the authentication response has an error code
* @throws IOException some other kind of I/O exception
*/
public TokenInfoResponse requestTokenInfo() throws IOException {
HttpTransport authSubTransport = this.authSubTransport;
HttpRequest request = authSubTransport.createRequestFactory().buildGetRequest(
new GenericUrl("https://www.google.com/accounts/AuthSubTokenInfo"));
request.addParser(AuthKeyValueParser.INSTANCE);
return request.execute().parseAs(TokenInfoResponse.class);
}
代码示例来源:origin: com.google.api.client/google-api-client-googleapis
/**
* Exchanges the single-use token for a session token as described in <a href=
* "http://code.google.com/apis/accounts/docs/AuthSub.html#AuthSubSessionToken"
* >AuthSubSessionToken</a>. Sets the authorization header of the Google transport using the
* session token, and automatically sets the token used by this instance using
* {@link #setToken(String)}.
* <p>
* Note that Google allows at most 10 session tokens per use per web application, so the session
* token for each user must be persisted.
*
* @return session token
* @throws HttpResponseException if the authentication response has an error code
* @throws IOException some other kind of I/O exception
*/
public String exchangeForSessionToken() throws IOException {
HttpTransport authSubTransport = this.authSubTransport;
HttpRequest request = authSubTransport.createRequestFactory().buildGetRequest(
new GenericUrl("https://www.google.com/accounts/AuthSubSessionToken"));
request.addParser(AuthKeyValueParser.INSTANCE);
SessionTokenResponse sessionTokenResponse =
request.execute().parseAs(SessionTokenResponse.class);
String sessionToken = sessionTokenResponse.sessionToken;
setToken(sessionToken);
return sessionToken;
}
代码示例来源:origin: com.google.api.client/google-api-client-googleapis
/**
* Authenticates based on the provided field values.
*
* @throws HttpResponseException if the authentication response has an error code, such as for a
* CAPTCHA challenge. Call {@link HttpResponseException#response exception.response}.
* {@link HttpResponse#parseAs(Class) parseAs}({@link ClientLogin.ErrorInfo
* ClientLoginAuthenticator.ErrorInfo}.class) to parse the response.
* @throws IOException some other kind of I/O exception
*/
public Response authenticate() throws HttpResponseException, IOException {
GenericUrl url = serverUrl.clone();
url.appendRawPath("/accounts/ClientLogin");
UrlEncodedContent content = new UrlEncodedContent();
content.data = this;
HttpRequest request = transport.createRequestFactory().buildPostRequest(url, content);
request.addParser(AuthKeyValueParser.INSTANCE);
request.disableContentLogging = true;
return request.execute().parseAs(Response.class);
}
}
内容来源于网络,如有侵权,请联系作者删除!