What is this value for authtokentype suppose to be for Facebook using
AccountManager.getAuthToken? My code below will present the screen
prompting the user to allow my application access to the users
facebook account. If the user denies my application access then the
next time they launch the application, it will ask again. If the user
allows access to the account, the screen is not shown again (the way I
would it expect it to function). Once the user allows access, whenever
I try to get the token, I get an AuthenticationException with message
- 'No Response From Authenticator'. Any help would be most
appreciated!
public class StartUp extends Activity {
final String TAG ="Sync";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AccountManager mgr = AccountManager.get(this);
AuthenticatorDescription[] authTypes =
mgr.getAuthenticatorTypes();
//list the authenticators available to me. Facebook is
available
for(int q=0;q<authTypes.length;q++)
{
Log.d(TAG,"AuthenticatorType packagename - "+authTypes
[q].packageName );
Log.d(TAG,"AuthenticatorType label - "+authTypes
[q].labelId );
Log.d(TAG,"AuthenticatorType type - "+authTypes[q].type );
Log.d(TAG,"AuthenticatorType accountPreferencesId -
"+authTypes[q].accountPreferencesId );
}
//get the facebook account
Account[] accts = mgr.getAccountsByType
("com.facebook.auth.login");
Account acct = null;
for(int i=0;i<accts.length;i++) {
acct = accts[i];
Log.d(TAG, "account - name="+acct.name+",
type="+acct.type); //facebook account
mgr.getAuthToken(acct, "com.facebook.auth.login",null, this,
new CallbackSync(), null);
}
}
private class CallbackSync implements AccountManagerCallback {
public void run(AccountManagerFuture future)
{
try{
Log.i(TAG, "isDone2? "+future.isDone()); //should
always be true
in callback
Log.i(TAG, "isCanceled? "+future.isCancelled());
//canceled if
the user denies access
Bundle b = (Bundle)future.getResult(); //thows
exception once the
user allows access
Log.d(TAG, "ACTION_AUTHENTICATOR_INTENT="+b.get
(AccountManager.ACTION_AUTHENTICATOR_INTENT));
Log.d(TAG, "KEY_ACCOUNT_AUTHENTICATOR_RESPONSE="+b.get
(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE));
Log.d(TAG, "KEY_ACCOUNT_NAME="+b.get
(AccountManager.KEY_ACCOUNT_NAME));
Log.d(TAG, "KEY_AUTH_FAILED_MESSAGE="+b.get
(AccountManager.KEY_AUTH_FAILED_MESSAGE));
Log.d(TAG, "KEY_AUTHTOKEN="+b.get
(AccountManager.KEY_AUTHTOKEN)); //this is where I woulde expect to
see the token to use
Log.d(TAG, "KEY_AUTH_TOKEN_LABEL="+b.get
(AccountManager.KEY_AUTH_TOKEN_LABEL));
Log.d(TAG, "KEY_ERROR_MESSAGE="+b.get
(AccountManager.KEY_ERROR_MESSAGE));
Log.d(TAG, "KEY_INTENT="+b.get(AccountManager.KEY_INTENT));
}catch(AuthenticatorException ae)
{
ae.printStackTrace();
Log.e(TAG,
"AuthenticatorException-"+ae.getMessage());
}
catch(IOException ioe)
{
Log.e(TAG, ioe.getMessage());
}
catch(OperationCanceledException oce)
{
Log.e(TAG,
"OperationCanceledException-"+oce.getMessage());
}
}
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en