diff --git a/README.md b/README.md index 52995a6..26d64e0 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ import { SpotifyApi } from '@sspenst/spotify-web-api'; // Choose one of the following: const sdk = SpotifyApi.withUserAuthorization("client-id", "http://127.0.0.1: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. diff --git a/example_node/package-lock.json b/example_node/package-lock.json index bd15fe2..2f68511 100644 --- a/example_node/package-lock.json +++ b/example_node/package-lock.json @@ -9,13 +9,13 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "dotenv": "^16.6.1" + "dotenv": "^17.2.3" } }, "node_modules/dotenv": { - "version": "16.6.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", - "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "version": "17.2.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz", + "integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==", "license": "BSD-2-Clause", "engines": { "node": ">=12" diff --git a/example_node/package.json b/example_node/package.json index c9397c0..8efa2cc 100644 --- a/example_node/package.json +++ b/example_node/package.json @@ -10,6 +10,6 @@ "author": "", "license": "ISC", "dependencies": { - "dotenv": "^16.6.1" + "dotenv": "^17.2.3" } } diff --git a/src/SpotifyApi.test.ts b/src/SpotifyApi.test.ts index 023fc2e..7770294 100644 --- a/src/SpotifyApi.test.ts +++ b/src/SpotifyApi.test.ts @@ -75,7 +75,7 @@ describe("SpotifyAPI Instance", () => { }); it("can create an instance with the client credentials strategy configured", async () => { - const sut = SpotifyApi.withClientCredentials("client-id", "secret", ["scope1", "scope2"]); + const sut = SpotifyApi.withClientCredentials("client-id", "secret"); expect(sut["authenticationStrategy"].constructor.name).toBe(ClientCredentialsStrategy.name); }); diff --git a/src/SpotifyApi.ts b/src/SpotifyApi.ts index d5eaf44..14f59fa 100644 --- a/src/SpotifyApi.ts +++ b/src/SpotifyApi.ts @@ -168,8 +168,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 { + 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..47ea2be 100644 --- a/src/auth/ClientCredentialsStrategy.ts +++ b/src/auth/ClientCredentialsStrategy.ts @@ -11,7 +11,6 @@ export default class ClientCredentialsStrategy implements IAuthStrategy { constructor( private clientId: string, private clientSecret: string, - private scopes: string[] = [] ) { } @@ -45,12 +44,6 @@ export default class ClientCredentialsStrategy implements IAuthStrategy { } private async getTokenFromApi(): Promise { - const options = { - grant_type: 'client_credentials', - scope: this.scopes.join(' ') - } as any; - - const bodyAsString = Object.keys(options).map(key => key + '=' + options[key]).join('&'); const hasBuffer = typeof Buffer !== 'undefined'; const credentials = `${this.clientId}:${this.clientSecret}`; @@ -64,7 +57,7 @@ export default class ClientCredentialsStrategy implements IAuthStrategy { "Content-Type": "application/x-www-form-urlencoded", "Authorization": `Basic ${basicAuth}` }, - body: bodyAsString + body: "grant_type=client_credentials" }); if (result.status !== 200) {