final AuthenticationRequest request = new AuthenticationRequest.Builder(CLIENT_ID, AuthenticationResponse.Type.TOKEN, REDIRECT_URI)
.setScopes(new String[]{"playlist-read"})
.build();
AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);
上記は、ログインボタンがクリックされたときに実行されるコードです。このコードは、エミュレーターで実行すると正常に機能します。以下はonActivityResultです。
if (requestCode == REQUEST_CODE) {
AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);
switch (response.getType()) {
// Response was successful and contains auth token
case TOKEN:
logMessage("Got token: " + response.getAccessToken());
CredentialsHandler.setToken(this, response.getAccessToken(), response.getExpiresIn(), TimeUnit.SECONDS);
startMainActivity(response.getAccessToken());
break;
// Auth flow returned an error
case ERROR:
logError("Auth error: " + response.getError());
break;
// Most likely auth flow was cancelled
default:
logError("Auth result: " + response.getType());
}
}
Spotifyアプリがインストールされているデバイスでアプリを実行すると、response.getType()はERRORを返し、response.getError()はINVALID_APP_IDになります。
私のアプリのパッケージ名とSHA-1フィンガープリントは、Spotifyの開発ポータルに入力されています。エミュレーターで動作するため、これは問題にはなりません。応答でトークンが送信されないのはなぜですか?前もって感謝します!
PS:明確にするために、これはSpotify APIの複製ではありません:INVALID_APP_ID
投稿の答えは、SHA-1フィンガープリントとパッケージ名をポータルに配置することですが、私はすでにそれを行っています。
https://developer.spotify.com/dashboard/のプロジェクト設定にSHA1フィンガープリントとパッケージ名の両方(デバッグとリリース)を追加する必要があります。
SHA1を取得する方法については、https://developers.google.com/android/guides/client-authを参照してください。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加