Skip to content

Commit

Permalink
Merge pull request #1 from KirtanSoni/remove-scope-param
Browse files Browse the repository at this point in the history
Remove scope param
  • Loading branch information
KirtanSoni authored Dec 22, 2023
2 parents 5d14751 + 6947cc4 commit 1f81f15
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { SpotifyApi } from '@spotify/web-api-ts-sdk';

// Choose one of the following:
const sdk = SpotifyApi.withUserAuthorization("client-id", "https://localhost:3000", ["scope1", "scope2"]);
const sdk = SpotifyApi.withClientCredentials("client-id", "secret", ["scope1", "scope2"]);
const sdk = SpotifyApi.withClientCredentials("client-id", "secret");
```

Each of these factory methods will return a `SpotifyApi` instance, which you can use to make requests to the Spotify Web API.
Expand Down
4 changes: 2 additions & 2 deletions src/SpotifyApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ export class SpotifyApi {
return new SpotifyApi(strategy, config);
}

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
const strategy = new ClientCredentialsStrategy(clientId, clientSecret);
return new SpotifyApi(strategy, config);
}

Expand Down
6 changes: 2 additions & 4 deletions src/auth/ClientCredentialsStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export default class ClientCredentialsStrategy implements IAuthStrategy {

constructor(
private clientId: string,
private clientSecret: string,
private scopes: string[] = []
private clientSecret: string
) {
}

Expand Down Expand Up @@ -46,8 +45,7 @@ export default class ClientCredentialsStrategy implements IAuthStrategy {

private async getTokenFromApi(): Promise<AccessToken> {
const options = {
grant_type: 'client_credentials',
scope: this.scopes.join(' ')
grant_type: 'client_credentials'
} as any;

const bodyAsString = Object.keys(options).map(key => key + '=' + options[key]).join('&');
Expand Down

0 comments on commit 1f81f15

Please sign in to comment.