Class ClientParametersAuthentication
- java.lang.Object
-
- com.google.api.client.auth.oauth2.ClientParametersAuthentication
-
- All Implemented Interfaces:
com.google.api.client.http.HttpExecuteInterceptor
,com.google.api.client.http.HttpRequestInitializer
public class ClientParametersAuthentication extends Object implements com.google.api.client.http.HttpRequestInitializer, com.google.api.client.http.HttpExecuteInterceptor
Client credentials specified as URL-encoded parameters in the HTTP request body as specified in Client PasswordThis implementation assumes that the
HttpRequest.getContent()
isnull
or an instance ofUrlEncodedContent
. This is used as the client authentication inTokenRequest.setClientAuthentication(HttpExecuteInterceptor)
.Sample usage:
static void requestAccessToken() throws IOException { try { TokenResponse response = new AuthorizationCodeTokenRequest(new NetHttpTransport(), new JacksonFactory(), 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.
- Since:
- 1.7
- Author:
- Yaniv Inbar
-
-
Constructor Summary
Constructors Constructor Description ClientParametersAuthentication(String clientId, String clientSecret)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getClientId()
Returns the client identifier issued to the client during the registration process.String
getClientSecret()
Returns the client secret ornull
for none.void
initialize(com.google.api.client.http.HttpRequest request)
void
intercept(com.google.api.client.http.HttpRequest request)
-
-
-
Method Detail
-
initialize
public void initialize(com.google.api.client.http.HttpRequest request) throws IOException
- Specified by:
initialize
in interfacecom.google.api.client.http.HttpRequestInitializer
- Throws:
IOException
-
intercept
public void intercept(com.google.api.client.http.HttpRequest request) throws IOException
- Specified by:
intercept
in interfacecom.google.api.client.http.HttpExecuteInterceptor
- Throws:
IOException
-
getClientId
public final String getClientId()
Returns the client identifier issued to the client during the registration process.
-
getClientSecret
public final String getClientSecret()
Returns the client secret ornull
for none.
-
-