From 3197d15197beeffe5cbbb45ea326407442894983 Mon Sep 17 00:00:00 2001 From: KirtanSoni Date: Thu, 21 Dec 2023 20:44:51 -0700 Subject: [PATCH 1/2] removed scope parameter from the constructor of ClientCredentialsStategy, its finale request and withClientCredentials method --- src/SpotifyApi.ts | 4 ++-- src/auth/ClientCredentialsStrategy.ts | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/SpotifyApi.ts b/src/SpotifyApi.ts index cc34386..72a9770 100644 --- a/src/SpotifyApi.ts +++ b/src/SpotifyApi.ts @@ -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); } diff --git a/src/auth/ClientCredentialsStrategy.ts b/src/auth/ClientCredentialsStrategy.ts index 414e049..11ffc7d 100644 --- a/src/auth/ClientCredentialsStrategy.ts +++ b/src/auth/ClientCredentialsStrategy.ts @@ -10,8 +10,7 @@ export default class ClientCredentialsStrategy implements IAuthStrategy { constructor( private clientId: string, - private clientSecret: string, - private scopes: string[] = [] + private clientSecret: string ) { } @@ -46,8 +45,7 @@ export default class ClientCredentialsStrategy implements IAuthStrategy { private async getTokenFromApi(): Promise { 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('&'); From 6947cc4f7f64846fd8e56c838ef60c5b1d884efe Mon Sep 17 00:00:00 2001 From: KirtanSoni Date: Thu, 21 Dec 2023 21:17:14 -0700 Subject: [PATCH 2/2] updated readme with the correct implimentation of ClientCredentialStrategy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ec5def..f90aa68 100644 --- a/README.md +++ b/README.md @@ -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.