Skip to content

Conversation

@KirtanSoni
Copy link

@KirtanSoni KirtanSoni commented Dec 22, 2023

Problem #95

The ClientCredentialsStrategy constructor included a 'scope' parameter, which was unnecessary and caused inconsistencies. Additionally, the main request in the same class included unnecessary scopes in the request body.

Solution

Refactored the ClientCredentialsStrategy constructor by removing the 'scope' parameter. Modified the main request handling in the same class to exclude unnecessary scopes from the request body. Updated the 'withClientCredentials' static method to align with the changes in the strategy.

Result

The ClientCredentialsStrategy now has a cleaner constructor without the 'scope' parameter, and the main request handling avoids including unnecessary scopes. The 'withClientCredentials' method is consistent with the updated strategy. The README has also been modified to reflect these changes.

@KirtanSoni KirtanSoni changed the title auth-module: Refactor ClientCredentialsStrategy constructor and request handling [FIX] auth-module: Refactor ClientCredentialsStrategy constructor and request handling Dec 22, 2023
@fostertheweb
Copy link
Contributor

I merged this change to my fork and released it to npm.

I made a small change so that existing code using withClientCredentials won't error for having the wrong number of arguments. I used method overloads and the JSDoc @deprecated tag so that when the 4th argument is passed in your code editor should inform you to remove the argument, but including it is still valid. You can see the changes here in the diff between the current and previous version.

@therealsujitk
Copy link

Not a member but I thought I'd review this since I was planning to create a PR with these changes.


public static withClientCredentials(clientId: string, clientSecret: string, scopes: string[] = [], config?: SdkOptions): SpotifyApi {
const strategy = new ClientCredentialsStrategy(clientId, clientSecret, scopes);
public static withClientCredentials(clientId: string, clientSecret: string, config?: SdkOptions): SpotifyApi {//change

Choose a reason for hiding this comment

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

You'll probably be asked to remove the //change comment from this line.

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.

3 participants