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
Modifier and Type | Class and Description |
---|---|
static class |
Google2Client.Google2Scope |
Modifier and Type | Field and Description |
---|---|
protected static String |
EMAIL_SCOPE |
protected static String |
PROFILE_SCOPE |
static String |
RESPONSE_TYPE_CODE |
protected Google2Client.Google2Scope |
scope |
protected String |
scopeValue |
logger, OAUTH_CODE
service
ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, callbackUrlResolver
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 com.github.scribejava.core.builder.api.BaseApi<com.github.scribejava.core.oauth.OAuth20Service> |
getApi()
Define the OAuth API for this client.
|
protected String |
getOAuthScope()
Define the OAuth scope for this client.
|
protected String |
getProfileUrl(com.github.scribejava.core.model.OAuth2AccessToken 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.
|
void |
setScope(Google2Client.Google2Scope scope) |
buildOAuthConfig, getOAuthCredentials, getStateData, getStateParameter, retrieveAuthorizationUrl, setStateData
addAccessTokenToProfile, getAccessToken, signRequest
createOAuthRequest, getConnectTimeout, getKey, getReadTimeout, getResponseType, getSecret, hasOAuthGrantType, isTokenAsHeader, retrieveCredentials, retrieveRedirectAction, retrieveUserProfile, retrieveUserProfileFromToken, sendRequestForData, setConnectTimeout, setKey, setReadTimeout, setResponseType, setSecret, setTokenAsHeader
computeFinalCallbackUrl, getAjaxRequestResolver, getCallbackUrl, getCallbackUrlResolver, getCredentials, getRedirectAction, isIncludeClientNameInCallbackUrl, redirect, setAjaxRequestResolver, setCallbackUrl, setCallbackUrlResolver, setIncludeClientNameInCallbackUrl
addAuthorizationGenerator, getAuthorizationGenerators, getName, getUserProfile, setAuthorizationGenerator, setAuthorizationGenerators, setAuthorizationGenerators, setName, toString
init, reinit
public static final String RESPONSE_TYPE_CODE
protected static final String PROFILE_SCOPE
protected static final String EMAIL_SCOPE
protected Google2Client.Google2Scope scope
protected String scopeValue
protected void internalInit(WebContext context)
InitializableWebObject
internalInit
in class BaseOAuthClient<Google2Profile,com.github.scribejava.core.oauth.OAuth20Service,com.github.scribejava.core.model.OAuth2AccessToken>
context
- the web contextprotected com.github.scribejava.core.builder.api.BaseApi<com.github.scribejava.core.oauth.OAuth20Service> getApi()
BaseOAuthClient
getApi
in class BaseOAuthClient<Google2Profile,com.github.scribejava.core.oauth.OAuth20Service,com.github.scribejava.core.model.OAuth2AccessToken>
protected String getOAuthScope()
BaseOAuthClient
getOAuthScope
in class BaseOAuthClient<Google2Profile,com.github.scribejava.core.oauth.OAuth20Service,com.github.scribejava.core.model.OAuth2AccessToken>
protected String getProfileUrl(com.github.scribejava.core.model.OAuth2AccessToken accessToken)
BaseOAuthClient
getProfileUrl
in class BaseOAuthClient<Google2Profile,com.github.scribejava.core.oauth.OAuth20Service,com.github.scribejava.core.model.OAuth2AccessToken>
accessToken
- only used when constructing dynamic urls from data in the tokenprotected Google2Profile extractUserProfile(String body) throws HttpAction
BaseOAuthClient
extractUserProfile
in class BaseOAuthClient<Google2Profile,com.github.scribejava.core.oauth.OAuth20Service,com.github.scribejava.core.model.OAuth2AccessToken>
body
- the response bodyHttpAction
- whether an additional HTTP action is requiredprotected boolean hasBeenCancelled(WebContext context)
BaseOAuthClient
hasBeenCancelled
in class BaseOAuthClient<Google2Profile,com.github.scribejava.core.oauth.OAuth20Service,com.github.scribejava.core.model.OAuth2AccessToken>
context
- the web context.public Google2Client.Google2Scope getScope()
public void setScope(Google2Client.Google2Scope scope)
Copyright © 2016. All rights reserved.