Skip to content

Commit bc44c25

Browse files
committed
fix: remove deprecated implicit grant strategy
1 parent 2635bbd commit bc44c25

File tree

5 files changed

+2
-88
lines changed

5 files changed

+2
-88
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ console.table(items.artists.items.map((item) => ({
6868

6969
- Authorization Code Flow with PKCE
7070
- Client Credentials Flow
71-
- Implicit Grant Flow
7271
- Mixed Server and Client Side Authentication
7372

7473
We do auto-token refresh when expired and a refresh token is available.

example/script.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { SpotifyApi } from "../src/index";
22
import AuthorizationCodeWithPKCEStrategy from "../src/auth/AuthorizationCodeWithPKCEStrategy";
33

4-
const implicitGrantStrategy = new AuthorizationCodeWithPKCEStrategy(
4+
const authStrategy = new AuthorizationCodeWithPKCEStrategy(
55
import.meta.env.VITE_SPOTIFY_CLIENT_ID,
66
import.meta.env.VITE_REDIRECT_TARGET,
77
['user-read-private', 'user-read-email', 'playlist-modify-public', 'playlist-modify-private, user-read-playback-state, user-modify-playback-state']
88
);
99

10-
const spotify = new SpotifyApi(implicitGrantStrategy);
10+
const spotify = new SpotifyApi(authStrategy);
1111
const profile = await spotify.currentUser.profile();
1212
console.log(profile);
1313

src/SpotifyApi.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { FetchApiMock } from "./test/FetchApiMock";
66
import { validAlbumResult } from "./test/data/validAlbumResult";
77
import AuthorizationCodeWithPKCEStrategy from "./auth/AuthorizationCodeWithPKCEStrategy";
88
import ClientCredentialsStrategy from "./auth/ClientCredentialsStrategy";
9-
import ImplicitGrantStrategy from "./auth/ImplicitGrantStrategy";
109
import ProvidedAccessTokenStrategy from "./auth/ProvidedAccessTokenStrategy";
1110
import { AccessToken, SdkOptions } from "./types";
1211
import InMemoryCachingStrategy from "./caching/InMemoryCachingStrategy";
@@ -80,11 +79,6 @@ describe("SpotifyAPI Instance", () => {
8079
expect(sut["authenticationStrategy"].constructor.name).toBe(ClientCredentialsStrategy.name);
8180
});
8281

83-
it("can create an instance with the implicit grant strategy configured", async () => {
84-
const sut = SpotifyApi.withImplicitGrant("client-id", "secret", ["scope1", "scope2"]);
85-
expect(sut["authenticationStrategy"].constructor.name).toBe(ImplicitGrantStrategy.name);
86-
});
87-
8882
it("can create an instance with the provided access token strategy configured", async () => {
8983
const sut = SpotifyApi.withAccessToken("client-id", {} as AccessToken);
9084
expect(sut["authenticationStrategy"].constructor.name).toBe(ProvidedAccessTokenStrategy.name);

src/SpotifyApi.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import IAuthStrategy, { isEmptyAccessToken } from "./auth/IAuthStrategy.js";
1515
import UsersEndpoints from "./endpoints/UsersEndpoints.js";
1616
import CurrentUserEndpoints from "./endpoints/CurrentUserEndpoints.js";
1717
import ClientCredentialsStrategy from "./auth/ClientCredentialsStrategy.js";
18-
import ImplicitGrantStrategy from "./auth/ImplicitGrantStrategy.js";
1918
import AuthorizationCodeWithPKCEStrategy from "./auth/AuthorizationCodeWithPKCEStrategy.js";
2019
import DefaultResponseDeserializer from "./serialization/DefaultResponseDeserializer.js";
2120
import DefaultResponseValidator from "./responsevalidation/DefaultResponseValidator.js";
@@ -174,11 +173,6 @@ export class SpotifyApi {
174173
return new SpotifyApi(strategy, config);
175174
}
176175

177-
public static withImplicitGrant(clientId: string, redirectUri: string, scopes: string[] = [], config?: SdkOptions): SpotifyApi {
178-
const strategy = new ImplicitGrantStrategy(clientId, redirectUri, scopes);
179-
return new SpotifyApi(strategy, config);
180-
}
181-
182176
/**
183177
* Use this when you're running in a Node environment, and accepting the access token from a client-side `performUserAuthorization` call.
184178
* You can also use this method if you already have an access token and don't want to use the built-in authentication strategies.

src/auth/ImplicitGrantStrategy.ts

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)