public class TwitterClient extends BaseOAuth10Client<TwitterProfile>
This class is the OAuth client to authenticate users in Twitter.
You can define if a screen should always been displayed for authorization confirmation by using the
setAlwaysConfirmAuthorization(boolean)
method (false
by default).
It returns a TwitterProfile
.
More information at https://dev.twitter.com/docs/api/1/get/account/verify_credentials
logger, OAUTH_TOKEN, OAUTH_VERIFIER, REQUEST_TOKEN
service
ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, callbackUrlResolver
Constructor and Description |
---|
TwitterClient() |
TwitterClient(String key,
String secret) |
Modifier and Type | Method and Description |
---|---|
protected TwitterProfile |
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.OAuth10aService> |
getApi()
Define the OAuth API for this client.
|
protected String |
getProfileUrl(com.github.scribejava.core.model.OAuth1Token accessToken)
Retrieve the url of the profile of the authenticated user for the provider.
|
protected boolean |
hasBeenCancelled(WebContext context)
Return if the authentication has been cancelled.
|
protected void |
internalInit(WebContext context)
Internal initialization of the object.
|
boolean |
isAlwaysConfirmAuthorization() |
void |
setAlwaysConfirmAuthorization(boolean alwaysConfirmAuthorization) |
addAccessTokenToProfile, getAccessToken, getOAuthCredentials, getRequestTokenSessionAttributeName, retrieveAuthorizationUrl, signRequest
buildOAuthConfig, createOAuthRequest, getConnectTimeout, getKey, getOAuthScope, getReadTimeout, getResponseType, getSecret, hasOAuthGrantType, isTokenAsHeader, retrieveCredentials, retrieveRedirectAction, retrieveUserProfile, retrieveUserProfileFromToken, sendRequestForData, setConnectTimeout, setKey, setReadTimeout, setResponseType, setSecret, setTokenAsHeader
computeFinalCallbackUrl, getAjaxRequestResolver, getCallbackUrl, getCallbackUrlResolver, getCredentials, getRedirectAction, getStateParameter, isIncludeClientNameInCallbackUrl, redirect, setAjaxRequestResolver, setCallbackUrl, setCallbackUrlResolver, setIncludeClientNameInCallbackUrl
addAuthorizationGenerator, getAuthorizationGenerators, getName, getUserProfile, setAuthorizationGenerator, setAuthorizationGenerators, setAuthorizationGenerators, setName, toString
init, reinit
protected void internalInit(WebContext context)
InitializableWebObject
internalInit
in class BaseOAuthClient<TwitterProfile,com.github.scribejava.core.oauth.OAuth10aService,com.github.scribejava.core.model.OAuth1Token>
context
- the web contextprotected com.github.scribejava.core.builder.api.BaseApi<com.github.scribejava.core.oauth.OAuth10aService> getApi()
BaseOAuthClient
getApi
in class BaseOAuthClient<TwitterProfile,com.github.scribejava.core.oauth.OAuth10aService,com.github.scribejava.core.model.OAuth1Token>
protected String getProfileUrl(com.github.scribejava.core.model.OAuth1Token accessToken)
BaseOAuthClient
getProfileUrl
in class BaseOAuthClient<TwitterProfile,com.github.scribejava.core.oauth.OAuth10aService,com.github.scribejava.core.model.OAuth1Token>
accessToken
- only used when constructing dynamic urls from data in the tokenprotected boolean hasBeenCancelled(WebContext context)
BaseOAuthClient
hasBeenCancelled
in class BaseOAuthClient<TwitterProfile,com.github.scribejava.core.oauth.OAuth10aService,com.github.scribejava.core.model.OAuth1Token>
context
- the web context.protected TwitterProfile extractUserProfile(String body) throws HttpAction
BaseOAuthClient
extractUserProfile
in class BaseOAuthClient<TwitterProfile,com.github.scribejava.core.oauth.OAuth10aService,com.github.scribejava.core.model.OAuth1Token>
body
- the response bodyHttpAction
- whether an additional HTTP action is requiredpublic boolean isAlwaysConfirmAuthorization()
public void setAlwaysConfirmAuthorization(boolean alwaysConfirmAuthorization)
Copyright © 2016. All rights reserved.