|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.api.client.auth.oauth2.ClientParametersAuthentication
public class ClientParametersAuthentication
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 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.
| Constructor Summary | |
|---|---|
ClientParametersAuthentication(String clientId,
String clientSecret)
|
|
| Method Summary | |
|---|---|
String |
getClientId()
Returns the client identifier issued to the client during the registration process. |
String |
getClientSecret()
Returns the client secret. |
void |
initialize(HttpRequest request)
|
void |
intercept(HttpRequest request)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ClientParametersAuthentication(String clientId,
String clientSecret)
clientId - client identifier issued to the client during the registration processclientSecret - client secret| Method Detail |
|---|
public void initialize(HttpRequest request)
throws IOException
initialize in interface HttpRequestInitializerIOException
public void intercept(HttpRequest request)
throws IOException
intercept in interface HttpExecuteInterceptorIOExceptionpublic final String getClientId()
public final String getClientSecret()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||