static String getRedirectUri(HttpServletRequest req) { GenericUrl requestUrl = new GenericUrl(req.getRequestURL().toString()); requestUrl.setRawPath("/getauthcodeservlet"); return requestUrl.build(); }
/** * Builds a URL relative to this app's root. */ public static String buildUrl(HttpServletRequest req, String relativePath) { GenericUrl url = new GenericUrl(req.getRequestURL().toString()); url.setRawPath(relativePath); return url.build(); }
private boolean overrideThisMethod(HttpRequest request) throws IOException { String requestMethod = request.getRequestMethod(); if (requestMethod.equals(HttpMethods.POST)) { return false; } if (requestMethod.equals(HttpMethods.GET) ? request.getUrl().build().length() > MAX_URL_LENGTH : overrideAllMethods) { return true; } return !request.getTransport().supportsMethod(requestMethod); }
public void intercept(HttpRequest request) throws IOException { try { String header; String token = this.token; PrivateKey privateKey = this.privateKey; if (token == null) { header = null; } else if (privateKey == null) { header = AuthSub.getAuthorizationHeaderValue(token); } else { header = AuthSub.getAuthorizationHeaderValue( token, privateKey, request.method.name(), request.url.build()); } request.headers.authorization = header; } catch (GeneralSecurityException e) { IOException wrap = new IOException(); wrap.initCause(e); throw wrap; } } }
flow.newAuthorizationUrl().setRedirectUri(WebUtil.buildUrl(req, "/oauth2callback")); url.set("approval_prompt", "force"); res.sendRedirect(url.build());
writer.write(request.getUrl().build()); writer.write(" "); writer.write(HTTP_VERSION);
temporaryToken.callback = callbackUrl.build(); temporaryToken.transport = httpTransport; final OAuthCredentialsResponse credentialsResponse = temporaryToken.execute();
String normalizedPath = normalized.build();
String imageUrl = getFileUrlBuilder .set("access_token", credential.getAccessToken()) .set("alt", "media").build();
.withReportingConfiguration(reportingConfiguration) .build(); when(authorizationHeaderProvider.getAuthorizationHeader(session, ENDPOINT_URL.build())) .thenReturn("fooauthheader"); when(userAgentCombiner.getUserAgent(anyString())).thenReturn("foouseragent"); adWordsLibConfiguration, reportResponseInterceptor); HttpRequestFactory requestFactory = helper.getHttpRequestFactory(ENDPOINT_URL.build(), version);