Class ClientParametersAuthentication (1.33.3)

public class ClientParametersAuthentication implements HttpRequestInitializer, HttpExecuteInterceptor

Client credentials specified as URL-encoded parameters in the HTTP request body as specified in Client Password

This implementation assumes that the HttpRequest#getContent() is null or an instance of UrlEncodedContent. This is used as the client authentication in TokenRequest#setClientAuthentication(HttpExecuteInterceptor).

Sample usage:

static void requestAccessToken() throws IOException { try { TokenResponse response = new AuthorizationCodeTokenRequest(new NetHttpTransport(), new GsonFactory(), new GenericUrl("https://server.example.com/token"), "SplxlOBeZQQYbYS6WxSbIA").setRedirectUri("https://client.example.com/rd") .setClientAuthentication( new ClientParametersAuthentication("s6BhdRkqt3", "7Fjfp0ZBr1KtDRbnfVdmIw")).execute(); System.out.println("Access token: " + response.getAccessToken()); } catch (TokenResponseException e) { if (e.getDetails() != null) { System.err.println("Error: " + e.getDetails().getError()); if (e.getDetails().getErrorDescription() != null) { System.err.println(e.getDetails().getErrorDescription()); } if (e.getDetails().getErrorUri() != null) { System.err.println(e.getDetails().getErrorUri()); } } else { System.err.println(e.getMessage()); } } }

Implementation is immutable and thread-safe.

Inheritance

java.lang.Object > ClientParametersAuthentication

Implements

com.google.api.client.http.HttpRequestInitializer, com.google.api.client.http.HttpExecuteInterceptor

Constructors

ClientParametersAuthentication(String clientId, String clientSecret)

public ClientParametersAuthentication(String clientId, String clientSecret)
Parameters
NameDescription
clientIdString

client identifier issued to the client during the registration process

clientSecretString

client secret or null for none

Methods

getClientId()

public final String getClientId()

Returns the client identifier issued to the client during the registration process.

Returns
TypeDescription
String

getClientSecret()

public final String getClientSecret()

Returns the client secret or null for none.

Returns
TypeDescription
String

initialize(HttpRequest request)

public void initialize(HttpRequest request)
Parameter
NameDescription
requestcom.google.api.client.http.HttpRequest
Exceptions
TypeDescription
IOException

intercept(HttpRequest request)

public void intercept(HttpRequest request)
Parameter
NameDescription
requestcom.google.api.client.http.HttpRequest
Exceptions
TypeDescription
IOException