Java Code Examples for com.google.api.client.util.Data#mapOf()

The following examples show how to use com.google.api.client.util.Data#mapOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MicrosoftParametersAuthentication.java    From codenvy with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void intercept(HttpRequest request) throws IOException {
  Map<String, Object> data = Data.mapOf(UrlEncodedContent.getContent(request).getData());
  if (clientSecret != null) {
    data.put("client_assertion", clientSecret);
  }
  data.put("client_assertion_type", CLIENT_ASSERTION_TYPE);
  data.put("grant_type", GRANT_TYPE);
}
 
Example 2
Source File: ClientParametersAuthentication.java    From google-oauth-java-client with Apache License 2.0 5 votes vote down vote up
public void intercept(HttpRequest request) throws IOException {
  Map<String, Object> data = Data.mapOf(UrlEncodedContent.getContent(request).getData());
  data.put("client_id", clientId);
  if (clientSecret != null) {
    data.put("client_secret", clientSecret);
  }
}
 
Example 3
Source File: BearerToken.java    From google-oauth-java-client with Apache License 2.0 4 votes vote down vote up
private static Map<String, Object> getData(HttpRequest request) {
  return Data.mapOf(UrlEncodedContent.getContent(request).getData());
}
 
Example 4
Source File: AuthorizationCodeFlow.java    From google-oauth-java-client with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a new instance of an authorization code token request based on the given authorization
 * code.
 *
 * <p>
 * This is used to make a request for an access token using the authorization code. It uses
 * {@link #getTransport()}, {@link #getJsonFactory()}, {@link #getTokenServerEncodedUrl()},
 * {@link #getClientAuthentication()}, {@link #getRequestInitializer()}, and {@link #getScopes()}.
 * </p>
 *
 * <pre>
static TokenResponse requestAccessToken(AuthorizationCodeFlow flow, String code)
    throws IOException, TokenResponseException {
  return flow.newTokenRequest(code).setRedirectUri("https://client.example.com/rd").execute();
}
 * </pre>
 *
 * @param authorizationCode authorization code.
 */
public AuthorizationCodeTokenRequest newTokenRequest(String authorizationCode) {
  HttpExecuteInterceptor pkceClientAuthenticationWrapper = new HttpExecuteInterceptor() {
    @Override
    public void intercept(HttpRequest request) throws IOException {
      clientAuthentication.intercept(request);
      if (pkce != null) {
        Map<String, Object> data = Data.mapOf(UrlEncodedContent.getContent(request).getData());
        data.put("code_verifier", pkce.getVerifier());
      }
    }
  };

  return new AuthorizationCodeTokenRequest(transport, jsonFactory,
      new GenericUrl(tokenServerEncodedUrl), authorizationCode).setClientAuthentication(
      pkceClientAuthenticationWrapper).setRequestInitializer(requestInitializer).setScopes(scopes);
}