spotify webapi auth and requests

for the past few weeks ive been trying to implement spotify webapi on my app to auth users, get their pfp and handler and also get their currently playing track name and artist name but had no success. id appreciate any help.

AuthViewModel:

package com.example.grooveshare.viewmodels

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.result.ActivityResultLauncher
import androidx.lifecycle.ViewModel
import net.openid.appauth.*
import java.security.MessageDigest
import java.security.SecureRandom
import java.util.Base64

class SpotifyAuthViewModel : ViewModel() {

    private val clientId = ""
    private val redirectUri = "myapp://callback"
    private val authorizationEndpoint = "https://accounts.spotify.com/authorize"
    private val tokenEndpoint = "https://accounts.spotify.com/api/token"
    private val codeVerifier = generateCodeVerifier()
    private lateinit var authService: AuthorizationService

    fun initializeAuthService(context: Context) {
        authService = AuthorizationService(context)
        Log.d("SpotifyAuth", "AuthorizationService initialized")
    }

    private fun generateCodeVerifier(): String {
        val secureRandom = SecureRandom()
        val codeVerifier = ByteArray(32)
        secureRandom.nextBytes(codeVerifier)
        return Base64.getUrlEncoder().withoutPadding().encodeToString(codeVerifier)
    }

    private fun generateCodeChallenge(verifier: String): String {
        val bytes = verifier.toByteArray(Charsets.US_ASCII)
        val messageDigest = MessageDigest.getInstance("SHA-256")
        val digest = messageDigest.digest(bytes)
        return Base64.getUrlEncoder().withoutPadding().encodeToString(digest)
    }

    fun authenticate(authResultLauncher: ActivityResultLauncher<Intent>) {
        if (!::authService.isInitialized) {
            Log.e("SpotifyAuth", "AuthorizationService is not initialized")
            return
        }

        val serviceConfig = AuthorizationServiceConfiguration(
            Uri.parse(authorizationEndpoint),
            Uri.parse(tokenEndpoint)
        )

        val authRequest = AuthorizationRequest.Builder(
            serviceConfig,
            clientId,
            ResponseTypeValues.CODE,
            Uri.parse(redirectUri)
        ).setCodeVerifier(codeVerifier, generateCodeChallenge(codeVerifier), "S256")
            .setScope("user-read-currently-playing")
            .build()

        Log.d("SpotifyAuth", "Authorization Request URI: ${authRequest.toUri()}")

        val authIntent = authService.getAuthorizationRequestIntent(authRequest)
        authResultLauncher.launch(authIntent) // Launch the auth intent using the Activity Result API
    }

    fun handleAuthResponse(intent: Intent?) {
        if (intent == null) {
            Log.e("SpotifyAuth", "Intent is null")
            return
        }

        Log.d("SpotifyAuth", "Handling Intent: $intent")
        Log.d("SpotifyAuth", "Intent Data: ${intent.data}")
        Log.d("SpotifyAuth", "Intent Extras: ${intent.extras}")

        val authorizationResponse = AuthorizationResponse.fromIntent(intent)
        val authorizationException = AuthorizationException.fromIntent(intent)

        if (authorizationResponse != null) {
            Log.d("SpotifyAuth", "Authorization Response: ${authorizationResponse.jsonSerializeString()}")
            val tokenRequest = authorizationResponse.createTokenExchangeRequest()

            authService.performTokenRequest(tokenRequest) { tokenResponse, exception ->
                if (tokenResponse != null) {
                    Log.d("SpotifyAuth", "Token Response: ${tokenResponse.jsonSerializeString()}")
                    val accessToken = tokenResponse.accessToken
                    Log.d("SpotifyAuth", "Access Token: $accessToken")
                } else {
                    Log.e("SpotifyAuth", "Token Exchange Failed: ${exception?.errorDescription}")
                }
            }
        } else {
            Log.e("SpotifyAuth", "Authorization Failed: ${authorizationException?.errorDescription}")
        }
    }

    override fun onCleared() {
        super.onCleared()
        if (::authService.isInitialized) {
            authService.dispose()
        }
    }
}

the logs i get everytime the app runs are the following:

17:13:05.657 8857-8857 SpotifyAuth com.example.grooveshare D AuthorizationService initialized

17:13:05.662 8857-8857 SpotifyAuth com.example.grooveshare D Authorization Request URI: https://accounts.spotify.com/authorize?redirect_uri=myapp%3A%2F%2Fcallback&client_id=7ac6f34f4fd947d8abee1dbbcbc478f5&response_type=code&state=Yp97iSWgmoqqbVBzqzE3Dw&nonce=z1bk_2FURFxkkBHUtn-G2Q&scope=user-read-currently-playing&code_challenge=4IFKhxrW5p_PMYYnxoJ2KAvVbvErr4I4ZXtb8Sgy8SM&code_challenge_method=S256

17:13:11.010 8857-8857 SpotifyAuth com.example.grooveshare E Intent is null

steps ive taken so far:

made sure my redirect uri stated in the viewmodel is the same w the one stated in spotify dashboard and also that the intent is correctly established in AndroidManifest.xml

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật