com.spotify.sdk.android.authentication.AuthenticationResponse Java Examples
The following examples show how to use
com.spotify.sdk.android.authentication.AuthenticationResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpotifyManagerImpl.java From mirror with Apache License 2.0 | 6 votes |
@Override public void onAuthenticationResult(int requestCode, int resultCode, Intent data) { if (requestCode != SpotifyManager.REQUEST_CODE) { return; } AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data); switch (response.getType()) { case TOKEN: onAuthenticationComplete(response.getAccessToken()); break; case ERROR: Timber.e("Auth error: %s", response.getError()); break; default: Timber.e("Auth result: %s", response.getType()); } }
Example #2
Source File: LoginActivity.java From spotify-web-api-android with MIT License | 6 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); // Check if result comes from the correct activity 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()); } } }
Example #3
Source File: CPlaylistActivity.java From YTPlayer with GNU General Public License v3.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE) { AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data); switch (response.getType()) { // Response was successful and contains auth token case TOKEN: Log.e(TAG, "onActivityResult: "+response.getAccessToken() ); Log.e(TAG,"Expires in: "+response.getExpiresIn()); alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setVisibility(View.GONE); alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); Toast.makeText(this, "Success: connected to Spotify app!", Toast.LENGTH_SHORT).show(); accessToken = response.getAccessToken(); break; case ERROR: Log.e(TAG, "onActivityResult: "+response.getError() ); alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setVisibility(View.VISIBLE); Toast.makeText(this, "Couldn't connect to Spotify!", Toast.LENGTH_SHORT).show(); break; } } }
Example #4
Source File: SpotifyLoginActivity.java From android-spotify-demo with MIT License | 5 votes |
@Override protected void onActivityResult(int requestCode, final int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == REQUEST_CODE) { final AuthenticationResponse response = AuthenticationClient.getResponse(resultCode, data); switch (response.getType()) { // Response was successful and contains auth token case TOKEN: Intent intent = new Intent(SpotifyLoginActivity.this, MainActivity.class); intent.putExtra(AUTH_TOKEN, response.getAccessToken()); startActivity(intent); destroy(); break; // Auth flow returned an error case ERROR: Log.e(TAG,"Auth error: " + response.getError()); break; // Most likely auth flow was cancelled default: Log.d(TAG,"Auth result: " + response.getType()); } } }
Example #5
Source File: SpotifyManagerImpl.java From mirror with Apache License 2.0 | 5 votes |
@Override public void doAuthentication() { final AuthenticationRequest request = new AuthenticationRequest .Builder(mClientId, AuthenticationResponse.Type.TOKEN, mClientRedirect) .setScopes(new String[]{"streaming", "playlist-read-private", "user-library-read",}) .build(); AuthenticationClient.openLoginActivity(mPluginFeatureManager.getForegroundActivity(), REQUEST_CODE, request); }
Example #6
Source File: MainActivity.java From Pasta-for-Spotify with Apache License 2.0 | 5 votes |
private void openRequest() { AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(pasta.CLIENT_ID, AuthenticationResponse.Type.TOKEN, REDIRECT_URI); builder.setScopes(new String[]{"user-read-private", "user-read-email", "streaming", "user-follow-read", "user-follow-modify", "user-library-read", "playlist-read-private", "playlist-modify-public", "playlist-modify-private"}); AuthenticationRequest request = builder.build(); AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request); }
Example #7
Source File: LoginActivity.java From spotify-web-api-android with MIT License | 5 votes |
public void onLoginButtonClicked(View view) { 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); }
Example #8
Source File: CPlaylistActivity.java From YTPlayer with GNU General Public License v3.0 | 3 votes |
void commonSpotifyConnect(String urltosearch) { AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID, AuthenticationResponse.Type.TOKEN, REDIRECT_URI); builder.setScopes(new String[]{"streaming"}); AuthenticationRequest request = builder.build(); AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request); }
Example #9
Source File: SpotifyLoginActivity.java From android-spotify-demo with MIT License | 3 votes |
private void openLoginWindow() { AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID, AuthenticationResponse.Type.TOKEN,REDIRECT_URI); builder.setScopes(new String[]{"user-read-private", "streaming", "user-top-read", "user-read-recently-played"}); AuthenticationRequest request = builder.build(); AuthenticationClient.openLoginActivity(this, REQUEST_CODE, request); }