# Class ClientParametersAuthentication (1.39.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.39.0 (latest)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.ClientParametersAuthentication)
- [1.38.2](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.38.2/com.google.api.client.auth.oauth2.ClientParametersAuthentication)
- [1.37.0](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.37.0/com.google.api.client.auth.oauth2.ClientParametersAuthentication)
- [1.36.0](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.36.0/com.google.api.client.auth.oauth2.ClientParametersAuthentication)
- [1.34.1](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.34.1/com.google.api.client.auth.oauth2.ClientParametersAuthentication)
- [1.33.3](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.33.3/com.google.api.client.auth.oauth2.ClientParametersAuthentication)
- [1.32.1](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/1.32.1/com.google.api.client.auth.oauth2.ClientParametersAuthentication)

    public class ClientParametersAuthentication implements HttpRequestInitializer, HttpExecuteInterceptor

Client credentials specified as URL-encoded parameters in the HTTP request body as specified in
[Client Password](http://tools.ietf.org/html/rfc6749#section-2.3.1)

This implementation assumes that the [HttpRequest#getContent()](https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpRequest.html#com_google_api_client_http_HttpRequest_getContent_) is `null` or an
instance of UrlEncodedContent. This is used as the client authentication in [TokenRequest#setClientAuthentication(HttpExecuteInterceptor)](https://docs.cloud.google.com/java/docs/reference/google-oauth-client/latest/com.google.api.client.auth.oauth2.TokenRequest#com_google_api_client_auth_oauth2_TokenRequest_setClientAuthentication_com_google_api_client_http_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](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> ClientParametersAuthentication

## Implements

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

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Constructors

### ClientParametersAuthentication(String clientId, String clientSecret)

    public ClientParametersAuthentication(String clientId, String clientSecret)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `clientId` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` client identifier issued to the client during the registration process |
| `clientSecret` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` 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** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### getClientSecret()

    public final String getClientSecret()

Returns the client secret or `null` for none.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### initialize(HttpRequest request)

    public void initialize(HttpRequest request)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `com.google.api.client.http.HttpRequest` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |

### intercept(HttpRequest request)

    public void intercept(HttpRequest request)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `request` | `com.google.api.client.http.HttpRequest` |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |