Announcements

Help Wizard

Step 1

NEXT STEP

Blank Login Screen using AuthenticationClient

Blank Login Screen using AuthenticationClient

Plan

Premium

Country

USA

 

Device

Pixel 3a Virtual Device (API 28)

Operating System

Android 9.0 Pie

 

My Question or Issue

I'm using the AuthenticationRequest and AuthenticationClient to connect a Spotify account to my app. After testing a few times with installing the app, logging in through the Login Activity, deleting the app, and repeating, the log in screen started turning out blank. No matter what I do, now, I can't get the login screen back.

 

I've tried using different devises, wiping the device and reinstalling, restarting my IDE, and using different OS versions.

 

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
Objects.requireNonNull(getSupportActionBar()).hide();
setContentView(R.layout.activity_splash);

authenticateSpotify();

sharedPreferences = this.getSharedPreferences("SPOTIFY", 0);
queue = Volley.newRequestQueue(this);
}

private void authenticateSpotify() {
AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID, AuthenticationResponse.Type.TOKEN, REDIRECT_URI);
builder.setScopes(new String[]{SCOPES});
AuthenticationRequest request = builder.build();
AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);

if (requestCode == REQUEST_CODE) {
AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, intent);

switch (response.getType()) {
case TOKEN:
editor = getSharedPreferences("SPOTIFY", 0).edit();
editor.putString("token", response.getAccessToken());
editor.apply();
waitForUserInfo();
break;

case ERROR:
default:
break;
}
}
}

private void waitForUserInfo() {
UserService userService = new UserService(queue, sharedPreferences);
userService.getUserInfo(() -> {
User user = userService.getUser();
editor = getSharedPreferences("SPOTIFY", 0).edit();
editor.putString("userid", user.id);
editor.putString("email", user.email);
editor.putString("name", user.display_name);
editor.commit();
startMainActivity();
});
}

private void startMainActivity() {
Intent newIntent = new Intent(AuthenticateSpotify.this, MainActivity.class);
startActivity(newIntent);
}

 

Screen Shot 2022-01-14 at 4.03.08 PM.png
Reply
1 Reply

Hey. Im actually having the a similar issue when trying to deploy my application with Vercel. It works fine on localhost. I have already tried to add the deployed redirect url to my Spotify application but only thing i get is a white screen with the message invalid redirect uri.

Suggested posts