org.shredzone.flattr4j.oauth
Class AndroidAuthenticator

java.lang.Object
  extended by org.shredzone.flattr4j.oauth.FlattrAuthenticator
      extended by org.shredzone.flattr4j.oauth.AndroidAuthenticator

public class AndroidAuthenticator
extends FlattrAuthenticator

An extension of FlattrAuthenticator that helps through the authentication process on Android devices.

Since:
2.3
Author:
Richard "Shred" Körber
See Also:
How to authenticate with flattr4j on Android

Constructor Summary
AndroidAuthenticator(String host, ConsumerKey consumerKey)
          Constructs a new instance with the given ConsumerKey.
AndroidAuthenticator(String host, String key, String secret)
          Constructs a new instance with the given consumer key and secret.
 
Method Summary
 android.content.Intent createAuthenticateIntent()
          Creates an Intent for forwarding the user to the Flattr web page for authentication.
 android.content.Intent createAuthenticateIntent(String state)
          Creates an Intent for forwarding the user to the Flattr web page for authentication.
 AccessToken fetchAccessToken(android.net.Uri uri)
          When the authentication was completed, your activity is resumed.
 String getState(android.net.Uri uri)
          Returns the state passed in with the Intent.
 
Methods inherited from class org.shredzone.flattr4j.oauth.FlattrAuthenticator
authenticate, authenticate, buildScopeString, createConnector, fetchAccessToken, getCallbackUrl, getResponseType, getScope, setCallbackUrl, setResponseType, setScope
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidAuthenticator

public AndroidAuthenticator(String host,
                            ConsumerKey consumerKey)
Constructs a new instance with the given ConsumerKey.

Parameters:
host - Host name that is configured in the manifest
consumerKey - ConsumerKey

AndroidAuthenticator

public AndroidAuthenticator(String host,
                            String key,
                            String secret)
Constructs a new instance with the given consumer key and secret.

Parameters:
host - Host name that is configured in the manifest
key - Consumer key
secret - Consumer secret
Method Detail

createAuthenticateIntent

public android.content.Intent createAuthenticateIntent()
                                                throws FlattrException
Creates an Intent for forwarding the user to the Flattr web page for authentication.

When the returned activity is started, a browser is opened. It shows a Flattr web page asking the user to authenticate and grant the requested scopes for your application.

When the authentication completes successfully, your activity is resumed with your callback URL passed in.

Returns:
Created Intent
Throws:
FlattrException

createAuthenticateIntent

public android.content.Intent createAuthenticateIntent(String state)
                                                throws FlattrException
Creates an Intent for forwarding the user to the Flattr web page for authentication.

When the returned activity is started, a browser is opened. It shows a Flattr web page asking the user to authenticate and grant the requested scopes for your application.

When the authentication completes successfully, your activity is resumed with your callback URL passed in.

Parameters:
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.
Returns:
Created Intent
Throws:
FlattrException

fetchAccessToken

public AccessToken fetchAccessToken(android.net.Uri uri)
                             throws FlattrException
When the authentication was completed, your activity is resumed. The callback URL carrying the authentication code is passed in with the Intent.

Parameters:
uri - Uri that was passed in with the the Intent, containing the callback URL from Flattr. It is safe to pass null here.
Returns:
AccessToken, or null if the Uri did not provide a valid code.
Throws:
FlattrException

getState

public String getState(android.net.Uri uri)
Returns the state passed in with the Intent. The state was set at createAuthenticateIntent(String).

Parameters:
uri - Uri that was passed in with the the Intent, containing the callback URL from Flattr. It is safe to pass null here.
Returns:
state, or null if no state was found


Copyright © 2010-2012. All Rights Reserved.