Skip to content

Authentication Token request return null access token with response type is empty #366

Open

Description

@muyassar

Issue found on 19 August 2024.

SDK Version:

com.spotify.android:auth:1.2.3

OS Version:

Android 13

Scope(s):

user-read-recently-played

Steps to reproduce:

  1. Request access token with auth api
val builder = AuthorizationRequest.Builder(context.getString(R.string.spotify_client_id),
                    AuthorizationResponse.Type.TOKEN, context.getString(R.string.spotify_callback_uri)
                )
                builder.setScopes(arrayOf("user-read-recently-played"))
                AuthorizationClient.openLoginActivity(activity, SPOTIFY_LOGIN_REQUEST_CODE, builder.build() )
  1. Get the response from on activity result
if(requestCode == Constants.SPOTIFY_LOGIN_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
            val response = AuthorizationClient.getResponse(resultCode, intent)
            val token = response.accessToken
            when(response.type) {
                AuthorizationResponse.Type.TOKEN -> {
                    val accessToken =  response.accessToken
                    Log.d("token", accessToken)
                }
                AuthorizationResponse.Type.EMPTY -> {
                    Log.d("empty", "empty")
                }
  1. Client ID and callback uri has been checked match from dashboard values.

Expected behaviour: response Type is TOKEN

Actual behaviour: response Type is EMPTY

Activity

  1. QuentinSuchet commented on Jan 18, 2025

    @QuentinSuchet

    Having the same issue, did you fix it ? :)

  2. AxelStein commented on Jan 18, 2025

    @AxelStein
  3. AxelStein commented on Jan 18, 2025

    @AxelStein
  4. QuentinSuchet commented on Jan 18, 2025

    @QuentinSuchet

    Got it working by using an ActivityResultContracts instead of the old OnActivityResult provided in the documentation and sample app :)

  5. AxelStein commented on Jan 18, 2025

    @AxelStein
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions