|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.shredzone.flattr4j.oauth.FlattrAuthenticator
public class FlattrAuthenticator
Helps through the OAuth2 authentication process at Flattr.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
String |
authenticate()
Authenticates this application against Flattr. |
String |
authenticate(String state)
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 |
getCallbackUrl()
A callback URL. |
EnumSet<Scope> |
getScope()
The access scope. |
void |
setCallbackUrl(String callbackUrl)
|
void |
setScope(EnumSet<Scope> scope)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FlattrAuthenticator(ConsumerKey consumerKey)
ConsumerKey
.
consumerKey
- ConsumerKey
public FlattrAuthenticator(String key, String secret)
key
- Consumer keysecret
- Consumer secretMethod Detail |
---|
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 setScope(EnumSet<Scope> scope)
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 String authenticate(String state) 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 parameters:
code
: the codestate
: the value of the state parameter that was givenScope flags need to be set properly before invocation.
state
- A value that is passed to the callback URL, to maintain state and
reidentify the user between request and callback. Optional, may be
null
.
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 Flattr
AccessToken
giving access to the Flattr API for the authenticated
user
FlattrException
protected Connector createConnector()
Connector
for sending requests.
Connector
protected String buildScopeString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |