public class GitHubClient extends BaseOAuth20Client<GitHubProfile>
This class is the OAuth client to authenticate users in GitHub.
The scope can be defined to require specific permissions from the user by using the setScope(String)
method. By default,
the scope is : user
.
It returns a GitHubProfile
.
More information at http://developer.github.com/v3/users/
GitHubProfile
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_SCOPE |
protected String |
scope |
logger, OAUTH_CODE
connectTimeout, key, proxyHost, proxyPort, readTimeout, secret, service, tokenAsHeader
ATTEMPTED_AUTHENTICATION_SUFFIX, callbackUrl, callbackUrlResolver, NEEDS_CLIENT_REDIRECTION_PARAMETER
Constructor and Description |
---|
GitHubClient() |
GitHubClient(String key,
String secret) |
Modifier and Type | Method and Description |
---|---|
protected GitHubProfile |
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.
|
String |
getScope() |
protected boolean |
hasBeenCancelled(WebContext context)
Return if the authentication has been cancelled.
|
protected void |
internalInit(WebContext context)
Internal initialization of the object.
|
protected GitHubClient |
newClient()
Create a new instance of the client.
|
void |
setScope(String scope) |
getAccessToken, getOAuthCredentials, isDirectRedirection, retrieveAuthorizationUrl
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
public static final String DEFAULT_SCOPE
protected String scope
protected GitHubClient newClient()
BaseClient
newClient
in class BaseClient<OAuthCredentials,GitHubProfile>
protected void internalInit(WebContext context)
InitializableWebObject
internalInit
in class BaseOAuthClient<GitHubProfile>
context
- the web contextprotected String getProfileUrl(org.scribe.model.Token accessToken)
BaseOAuthClient
getProfileUrl
in class BaseOAuthClient<GitHubProfile>
accessToken
- only used when constructing dynamic urls from data in the tokenprotected GitHubProfile extractUserProfile(String body)
BaseOAuthClient
extractUserProfile
in class BaseOAuthClient<GitHubProfile>
body
- the response bodyprotected boolean hasBeenCancelled(WebContext context)
BaseOAuthClient
hasBeenCancelled
in class BaseOAuthClient<GitHubProfile>
context
- the web context.public String getScope()
public void setScope(String scope)
Copyright © 2016. All rights reserved.