public class Google2Client extends BaseOAuth20StateClient<Google2Profile>
This class is the OAuth client to authenticate users in Google using OAuth protocol version 2.0.
The scope is by default : Google2Client.Google2Scope.EMAIL_AND_PROFILE
, but it can also but set to : Google2Client.Google2Scope.PROFILE
or Google2Client.Google2Scope.EMAIL
.
It returns a Google2Profile
.
More information at https://developers.google.com/accounts/docs/OAuth2Login
Google2Profile
Modifier and Type | Class and Description |
---|---|
static class |
Google2Client.Google2Scope |
Modifier and Type | Field and Description |
---|---|
protected String |
EMAIL_SCOPE |
protected String |
PROFILE_SCOPE |
protected Google2Client.Google2Scope |
scope |
protected String |
scopeValue |
logger, OAUTH_CODE
connectTimeout, key, proxyHost, proxyPort, readTimeout, secret, service, tokenAsHeader
ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, callbackUrlResolver, NEEDS_CLIENT_REDIRECTION_PARAMETER
Constructor and Description |
---|
Google2Client() |
Google2Client(String key,
String secret) |
Modifier and Type | Method and Description |
---|---|
protected Google2Profile |
extractUserProfile(String body)
Extract the user profile from the response (JSON, XML...) of the profile url.
|
protected String |
getProfileUrl(org.scribe.model.Token accessToken)
Retrieve the url of the profile of the authenticated user for the provider.
|
Google2Client.Google2Scope |
getScope() |
protected boolean |
hasBeenCancelled(WebContext context)
Return if the authentication has been cancelled.
|
protected void |
internalInit(WebContext context)
Internal initialization of the object.
|
protected Google2Client |
newClient()
Create a new instance of the client.
|
protected String |
retrieveAuthorizationUrl(WebContext context) |
void |
setScope(Google2Client.Google2Scope scope) |
void |
setUseStateParameter(boolean requiresStateParameter)
Enable or disable usage of the 'state' parameter as a CSRF protection in OAuth.
|
getAuthorizationUrl, getOAuthCredentials, getState, setState
getAccessToken, isDirectRedirection
addAccessTokenToProfile, clone, createProxyRequest, getClientType, getConnectTimeout, getKey, getProxyHost, getProxyPort, getReadTimeout, getSecret, getUserProfile, isTokenAsHeader, retrieveCredentials, retrieveRedirectAction, retrieveUserProfile, retrieveUserProfileFromToken, sendRequestForData, sendRequestForData, setConnectTimeout, setKey, setProxyHost, setProxyPort, setReadTimeout, setSecret, setTokenAsHeader
computeFinalCallbackUrl, getAjaxRequestResolver, getCallbackUrl, getCallbackUrlResolver, getCredentials, getRedirectAction, getRedirectionUrl, getStateParameter, isIncludeClientNameInCallbackUrl, redirect, setAjaxRequestResolver, setCallbackUrl, setCallbackUrlResolver, setIncludeClientNameInCallbackUrl
addAuthorizationGenerator, getAuthorizationGenerators, getName, getUserProfile, setAuthorizationGenerator, setAuthorizationGenerators, setAuthorizationGenerators, setName, toString
init, reinit
protected final String PROFILE_SCOPE
protected final String EMAIL_SCOPE
protected Google2Client.Google2Scope scope
protected String scopeValue
protected Google2Client newClient()
BaseClient
newClient
in class BaseClient<OAuthCredentials,Google2Profile>
protected void internalInit(WebContext context)
InitializableWebObject
internalInit
in class BaseOAuthClient<Google2Profile>
context
- the web contextprotected String getProfileUrl(org.scribe.model.Token accessToken)
BaseOAuthClient
getProfileUrl
in class BaseOAuthClient<Google2Profile>
accessToken
- only used when constructing dynamic urls from data in the tokenprotected Google2Profile extractUserProfile(String body)
BaseOAuthClient
extractUserProfile
in class BaseOAuthClient<Google2Profile>
body
- the response bodypublic Google2Client.Google2Scope getScope()
public void setScope(Google2Client.Google2Scope scope)
protected boolean hasBeenCancelled(WebContext context)
BaseOAuthClient
hasBeenCancelled
in class BaseOAuthClient<Google2Profile>
context
- the web context.public void setUseStateParameter(boolean requiresStateParameter)
requiresStateParameter
- whether the 'state' parameter must be usedprotected String retrieveAuthorizationUrl(WebContext context)
retrieveAuthorizationUrl
in class BaseOAuth20StateClient<Google2Profile>
Copyright © 2016. All rights reserved.