Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: force market as request option to search for shows #258

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Santiago-Balcero
Copy link

As put in this issue #257 calling for client.Search with SearchTypeShow was always returning zero values for Shows data.

When doing same request I got same issue, so when looking into Spotify Developer Forums here and here it turned out to be a Spotify unfixed issue since, at least, 2020.

The solution to this as put by the community is to add market as query parameter as in:

curl --location 'https://api.spotify.com/v1/search?q=cyclast&type=show&market=co' \
--header 'Authorization: Bearer your-token'

This PR has:

  • Enforces the use of market parameter when using client.Search with SearchTypeShow so client won't return zero values for correct search values.
  • Creates a unit test for client.Search with SearchTypeShow.
  • Adds CountryColombia.

search.go Outdated Show resolved Hide resolved
search.go Outdated Show resolved Hide resolved
@subash774
Copy link

after a quick local test session, I don't think market is the core issue here, when using curl or postman I can get the results without having to pass in the market parameter, something else is wrong, probably the way we're parsing the shows, will have a further look into it later
image

@subash774
Copy link

aplogies, I was wrong, found the issue - when using bearer token generated from developer.spotify.com, the returned json contains all the data we need, however, when we use the client id and secret to generate a bearer token on each request, using the token spotify returns does not return any shows unless market parameter is passed in. Issue is on spotify side, @zmb3 @strideynet not sure how you wanna proceed here

@Santiago-Balcero
Copy link
Author

Followed @subash774 suggestion on new Error. As seen on Spotify forums it is on their side. Waiting for @zmb3 and @strideynet answer to see if they will proceed with this PR or not. Anyways I will be glad to help.

@strideynet
Copy link
Collaborator

Thanks for raising this - I believe the market issue has been a "problem"/expected behaviour for a while. When using an access token, the native market of the user who the token is associated with is used. When only the Client ID/Secret is used, there is no default market to fall back on.

I'll take a look at this PR later today.

@@ -124,6 +129,10 @@ func (c *Client) Search(ctx context.Context, query string, t SearchType, opts ..
v.Set("q", query)
v.Set("type", t.encode())

if t == SearchTypeShow && v.Get("market") == "" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is specific to searching Shows - but I'm also not sure that returning an Error here is the right thing to do. Spotify could adjust their API behaviour in future. Perhaps we just need to better document that when using Client ID/Secret you need to specify the market as there's no default market.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, better documentation is probably the way to go as we don't control the scope of these params or if/when this issue really will get fixed. we can't decode the bearer token to get user info for us to implement the fallback method can we?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can't decode the bearer token to get user info for us to implement the fallback method can we?

I think we'd probably want to avoid that - even if the bearer token was decodable it'd probably be a bad idea for us to couple with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants