|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp
public class AuthorizationCodeInstalledApp
OAuth 2.0 authorization code flow for an installed Java application that persists end-user credentials.
Implementation is thread-safe.
| Constructor Summary | |
|---|---|
AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow,
VerificationCodeReceiver receiver)
|
|
| Method Summary | |
|---|---|
Credential |
authorize(String userId)
Authorizes the installed application to access user's protected data. |
static void |
browse(String url)
Open a browser at the given URL using Desktop if available, or alternatively output the
URL to System.out for command-line applications. |
AuthorizationCodeFlow |
getFlow()
Returns the authorization code flow. |
VerificationCodeReceiver |
getReceiver()
Returns the verification code receiver. |
protected void |
onAuthorization(AuthorizationCodeRequestUrl authorizationUrl)
Handles user authorization by redirecting to the OAuth 2.0 authorization server. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AuthorizationCodeInstalledApp(AuthorizationCodeFlow flow,
VerificationCodeReceiver receiver)
flow - authorization code flowreceiver - verification code receiver| Method Detail |
|---|
public Credential authorize(String userId)
throws Exception
userId - user ID or null if not using a persisted credential store
Exception
protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl)
throws Exception
Default implementation is to call browse(authorizationUrl.build()). Subclasses may
override to provide optional parameters such as the recommended state parameter. Sample
implementation:
@Override
protected void onAuthorization(AuthorizationCodeRequestUrl authorizationUrl) throws IOException {
authorizationUrl.setState("xyz");
super.onAuthorization(authorizationUrl);
}
authorizationUrl - authorization URL
Exception - exceptionpublic static void browse(String url)
Desktop if available, or alternatively output the
URL to System.out for command-line applications.
url - URL to browsepublic final AuthorizationCodeFlow getFlow()
public final VerificationCodeReceiver getReceiver()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||