私のアンドロイドアプリでFacebook AccountKitを使用しようとしています。ここでFacebook AccountKitError:400:内部一貫性エラーが発生しました:406:アクセストークンがありません:アカウントを取得できません。
は私のコードです:
loginPhoneNumber.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
phoneLogin(view);
}
});
public void phoneLogin(final View view) {
final Intent intent = new Intent(getBaseContext(), AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
LoginType.PHONE,
AccountKitActivity.ResponseType.CODE); // or .ResponseType.TOKEN
// ... perform additional configuration ...
intent.putExtra(
AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
configurationBuilder.build());
startActivityForResult(intent, APP_REQUEST_CODE);
}
ここonActivityResult()
です:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
if (requestCode == APP_REQUEST_CODE) { // confirm that this response matches your request
AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
String toastMessage;
if (loginResult.getError() != null) {
toastMessage = loginResult.getError().getErrorType().getMessage();
} else if (loginResult.wasCancelled()) {
toastMessage = "Login Cancelled";
} else {
if (loginResult.getAccessToken() != null) {
toastMessage = "Success:" + loginResult.getAccessToken().getAccountId();
} else {
toastMessage = String.format(
"Success: ",
loginResult.getAuthorizationCode());
}
// If you have an authorization code, retrieve it from
// loginResult.getAuthorizationCode()
// and pass it to your server and exchange it for an access token.
// Success! Start your next activity...
Intent intent = new Intent(SignUpActivity.this, MainActivity.class);
startActivity(intent);
}
// Surface the result to your user in an appropriate way.
Toast.makeText(
this,
toastMessage,
Toast.LENGTH_LONG)
.show();
}
}
私はSMSを通じて確認コードを取得するときにすべてがポイントに罰金起こっていると私はそのコードを入力し、MainActivity
が開かれます成功トーストが表示されます。
しかし、私のMainActivity
に、私はこのコードを使用しています:
accessToken
がnullで、それは私にこのエラーを与えて何が起こっているかである場合は、バックサインアップ画面にナビゲートし
com.facebook.accountkit.AccessToken accessToken = AccountKit.getCurrentAccessToken();
if (accessToken != null) {
//Handle Returning User
Toast.makeText(getBaseContext(), "Hello", Toast.LENGTH_SHORT).show();
} else {
//Handle new or logged out user
Intent intent = new Intent(MainActivity.this, SignUpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
Toast.makeText(getBaseContext(), "sent from 1", Toast.LENGTH_SHORT).show();
}
:com.facebook.accountkit.internal.LoginManager: No access token: cannot retrieve account
、これも印刷されつつあるがログアウト:AccountKitError: 400: An internal consistency error has occurred: 406: No access token: cannot retrieve account
ここで何が問題になりますか?なぜaccessToken
を入手できないのですか?