public class FlattrAuthenticator extends Object
Constructor and Description |
---|
FlattrAuthenticator(ConsumerKey consumerKey)
Constructs a new instance with the given
ConsumerKey . |
FlattrAuthenticator(String key,
String secret)
Constructs a new instance with the given consumer key and secret.
|
Modifier and Type | Method and Description |
---|---|
String |
authenticate()
Authenticates this application against Flattr.
|
protected String |
buildScopeString()
Builds a scope string for the scope flags set.
|
protected Connector |
createConnector()
Creates a
Connector for sending requests. |
AccessToken |
fetchAccessToken(String code)
Fetches an
AccessToken that gives access to the Flattr API. |
String |
getAccessTokenUrl()
The access token url required to retrieve the access token for flattr.com.
|
String |
getCallbackUrl()
A callback URL.
|
String |
getRequestTokenUrl()
The request token url.
|
String |
getResponseType() |
EnumSet<Scope> |
getScope()
The access scope.
|
void |
setAccessTokenUrl(String accessTokenUrl) |
void |
setCallbackUrl(String callbackUrl) |
void |
setRequestTokenUrl(String requestTokenUrl) |
void |
setResponseType(String responseType)
The OAuth response type.
|
void |
setScope(EnumSet<Scope> scope) |
public FlattrAuthenticator(ConsumerKey consumerKey)
ConsumerKey
.consumerKey
- ConsumerKey
public FlattrAuthenticator(String key, String secret)
key
- Consumer keysecret
- Consumer secretpublic String getRequestTokenUrl()
NOTE: This request token url must match the url defined at http://developers.flattr.net/api/#authorization
public void setRequestTokenUrl(String requestTokenUrl)
public String getAccessTokenUrl()
NOTE: This access token url must match the url defined at http://developers.flattr.net/api/#authorization
public void setAccessTokenUrl(String accessTokenUrl)
public String getCallbackUrl()
null
means that the user is required to retrieve the code
from Flattr and enter it manually. Use null
if you cannot provide a
callback URL, for example on a desktop or handheld device application.
NOTE: This callback URL must exactly match the URL that was used
on registration. Otherwise the authentication process will fail.
NOTE: If you registered your application as "client" type, callback url
must be null
.
Defaults to null
.
public void setCallbackUrl(String callbackUrl)
public EnumSet<Scope> getScope()
public void setResponseType(String responseType)
code
or token
, with the former
being the default.public String getResponseType()
public String authenticate() throws FlattrException
fetchAccessToken(String)
in order to complete the authorization.
When a callback url was set, Flattr will forward the user to this url with the following GET parameter:
code
: the codeScope flags need to be set properly before invocation.
FlattrException
public AccessToken fetchAccessToken(String code) throws FlattrException
AccessToken
that gives access to the Flattr API. After the user
entered the code (or when the callback url was invoked), this method is invoked to
complete the authorization process.
The returned access token can be serialized or the AccessToken.getToken()
persisted in a database. It is needed to access the Flattr API with a valid
authentication. The token is valid until revoked by the user.
code
- The code that was returned from FlattrAccessToken
giving access to the Flattr API for the authenticated
userFlattrException
protected Connector createConnector()
Connector
for sending requests.Connector
protected String buildScopeString()
Copyright © 2010–2017. All rights reserved.