2011-12-17 3 views
3

私はdeveloper.android.comにレッスンを追跡しようとしていますし、私は私がmyAccount_ためで置くために何を得ることはありません am.getAuthToken( myAccount_, AUTH_TOKEN_TYPE,options,this,new OnTokenAcquired(),new Handler(new OnError()));の認証

に立ち往生しています。アカウント配列にリンクされているアカウントですか? class OnTokenAcquiredAccount[] accounts = accountManager.getAccountsByType("com.google");

トークンの部分はまた、私はちょうどAccountManager.KEY_AUTHTOKENで一定になるようにsuposseであっても、それグローバルVAR確認する必要があり、それは、VARではないというエラーがgenneratingされますか?

This is the other link for the Authentication lessonとなりました。私はDIALOG_ACCOUNTSshowDialog(DIALOG_ACCOUNTS)manager.getAuthToken(account, AUTH_TOKEN_TYPE, null, activity, new AccountManagerCallback<Bundle>()でエラーが発生しています。私は現在、私が得ているエラーのためにそれ以上は進んでいません。

なぜこれらのエラーが発生しているのですか?私は正しいバールを入れていないのは私だけだと思う​​。

提案がありますか?

ここに私がコピーしたコードがあります。

public class AccountManagerActivity extends Activity { 

AccountManager accountManager = AccountManager.get(this); 

Account[] accounts = accountManager.getAccountsByType("com.google"); 

String AUTH_TOKEN_TYPE = "Manage your tasks"; 
String your_api_key; 
String your_client_id; 
String your_client_secret; 
String token; 

/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    URL url = new URL("https://www.googleapis.com/tasks/v1/users/@me/lists?key=" + your_api_key); 
    URLConnection conn = (HttpURLConnection) url.openConnection(); 

    conn.addRequestProperty("client_id", your_client_id); 

    conn.addRequestProperty("client_secret", your_client_secret); 

    conn.setRequestProperty("Authorization", "OAuth " + token); 



    AccountManager am = AccountManager.get(this); 
    Bundle options = new Bundle(); 

    am.invalidateAuthToken(token, AUTH_TOKEN_TYPE); 
    am.getAuthToken(
     /*Error here*/ myAccount_,      // Account retrieved using getAccountsByType() 
     AUTH_TOKEN_TYPE,    // Auth scope 
     options,      // Authenticator-specific options 
     this,       // Your activity 
     new OnTokenAcquired(),   // Callback called when a token is successfully acquired 
     new Handler(new OnError())); // Callback called if an error occurs 
} 

} 

そしてOnTokenAcquiredクラス

public class OnTokenAcquired implements AccountManagerCallback<Bundle> { 

public void run(AccountManagerFuture<Bundle> result) { 
    // TODO Auto-generated method stub 
    // Get the result of the operation from the AccountManagerFuture. 
    Bundle bundle = result.getResult(); 

    // The token is a named value in the bundle. The name of the value 
    // is stored in the constant AccountManager.KEY_AUTHTOKEN. 
    /*Error here*/ Token = bundle.getString(AccountManager.KEY_AUTHTOKEN); 
    Intent launch = (Intent) result./*Error here*/get(AccountManager.KEY_INTENT); 
    if (launch != null) { 
     /*Error here*/ startActivityForResult(launch, 0); 
     return; 
    } 


} 

} 
+0

あるべき@domshyraねえ、これは私のために働くために使用されるが、ほんの数日前にそれが動作を停止これでcom.google.android.gms.auth.GoogleAuthException:Unknownというこのエラーがスローされます。どんな考え?私のスコープに何か問題がありますか? https://gist.github.com/lawloretienne/7351151 – toobsco42

答えて

1
am.invalidateAuthToken(token, AUTH_TOKEN_TYPE); 

am.invalidateAuthToken(AUTH_TOKEN_TYPE, token);