Android AccountManager と OAuth について頭を悩ませようとしています。私がしたいのは、電話がパスワードにアクセスできないようにすることです。(これが Google の提案です。「セキュリティについて賢くなれ!」) そこで、Google のサンプル アプリケーションSampleSyncAdapterをチェックアウトし、コードを読み始めます。次に、AuthenticatorActivity でこれが発生するのを確認します。
private AccountManager mAccountManager;
private String mPassword;
/**
* ... Sets the
* AccountAuthenticatorResult which is sent back to the caller. We store the
* authToken that's returned from the server as the 'password' for this
* account - so we're never storing the user's actual password locally.
*
* @param result the confirmCredentials result.
*/
public void handleLogin(View view) {
....
mPassword = mPasswordEdit.getText().toString();
....
Log.d(TAG, "mPassword set to Account:" + mAccountManager.getPassword(account));
}
private void finishLogin(String authToken) {
....
mAccountManager.addAccountExplicitly(account, mPassword, null);
....
}
このログ メッセージは「mPassword set to Account:test」です。これは、このため、残りを読むとある程度理解できます
protected String doInBackground(Void... params) {
....
return NetworkUtilities.authenticate(mUsername, mPassword);
....
}
パスワードがトークンの場合、これは機能しません。
また、getAuthToken() の Authenticator で残りのコードが異なる動作をすることを期待します。何かについて完全に間違っていると思いますが、AccountManager を使用して OAuth「ダンス」の結果を保存し、このアカウントを使用できるようにしたいだけです。 JSON RESTful サービスを認証します。
誰でもこれに光を当てることができますか?