spotify-api.js: Client.user is undefined with user authorized token.

Bug Report

What I expected:

I expected the client to have a user property like the docs state.

What happened:

Instead client.user is undefined.

To reproduce this bug:

Get a token from Spotify. I am using the Authorization Code Flow with Proof Key for Code Exchange flow. I am using enough scopes to get the user data.

I make a client like this:

import {Client, UserClient} from "spotify-api.js";

const token = get_token();
const client = await new Client({
      token,
      userAuthorizedToken: true,
      cacheSettings: { cacheUser: true }});
console.log(Client.user)
console.log(await new UserClient(client))

This gives me back: undefined UserClient {type: "user", player: Player, client: Client}

Why is there no user property? The user client also does not have any of the properties described in the docs.

However, if I open up the userclient in the console that does have a user property and actually has my userโ€™s information in there but if I access it then it is undefined.

  • Library Version: v9.0.1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 31 (20 by maintainers)

Most upvoted comments

Thanks for the quick fix! Iโ€™ll give it a spin on the weekend and will let you know ๐Ÿ™Œ

Thanks, it works correctly now ๐Ÿ‘ ๐Ÿ™Œ