Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ INTEGRATION_TESTS_SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_for_tests
INTEGRATION_TESTS_USER_EMAIL=some@validuser.co.uk
INTEGRATION_TESTS_USER_PASSWORD=some-valid-password
VITE_SPOTIFY_CLIENT_ID=your_spotify_client_id_for_tests
VITE_REDIRECT_TARGET=http://localhost:3000
VITE_REDIRECT_TARGET=http://127.0.0.1:3000
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm run start

To run the tests, you need to have a Spotify account.

You will need to create a new app in the Spotify Developer portal, and add a redirect URI of `http://localhost:3000`.
You will need to create a new app in the Spotify Developer portal, and add a redirect URI of `http://127.0.0.1:3000`.

Add the following environment variables:

Expand All @@ -49,7 +49,7 @@ We support `dotenv`, so you can add these to a `.env` file in the root of the re
To run the embedded example app, you will need to add the following environment variables:

- `VITE_SPOTIFY_CLIENT_ID`=the same value as set in INTEGRATION_TESTS_SPOTIFY_CLIENT_ID
- `VITE_REDIRECT_TARGET`=http://localhost:3000
- `VITE_REDIRECT_TARGET`=http://127.0.0.1:3000

For the example app to work, this .env file needs to be in the ./example folder.

Expand All @@ -72,7 +72,7 @@ We follow the [GitHub Flow Workflow](https://guides.github.com/introduction/flow

To run the tests, you need to have a Spotify account.

You will need to create a new app in the Spotify Developer portal, and add a redirect URI of `http://localhost:3000`.
You will need to create a new app in the Spotify Developer portal, and add a redirect URI of `http://127.0.0.1:3000`.

You will need to add the following environment variables:

Expand All @@ -91,7 +91,7 @@ To run the embedded example app, you will need to add the following environment

```bash
VITE_SPOTIFY_CLIENT_ID=the same value as set in INTEGRATION_TESTS_SPOTIFY_CLIENT_ID
VITE_REDIRECT_TARGET=http://localhost:3000
VITE_REDIRECT_TARGET=http://127.0.0.1:3000
```

For the example app to work, this .env file needs to be in the ./example folder.
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Create a `.env` file in the example directory with your `client_id` and redirect

```bash .env
VITE_SPOTIFY_CLIENT_ID=your_spotify_client_id_for_tests
VITE_REDIRECT_TARGET=http://localhost:3000
VITE_REDIRECT_TARGET=http://127.0.0.1:3000
```

To run the app:
Expand All @@ -46,7 +46,7 @@ Creating an instance of the SDK is easy, and can be done in a number of ways dep
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.withUserAuthorization("client-id", "http://127.0.0.1:3000", ["scope1", "scope2"]);
const sdk = SpotifyApi.withClientCredentials("client-id", "secret", ["scope1", "scope2"]);
```

Expand Down Expand Up @@ -80,7 +80,7 @@ If you're building a browser based application, you should use Authorization Cod
Calling any of the methods on the SDK will automatically perform any redirects/refreshes that are necessary.

```js
const sdk = SpotifyApi.withUserAuthorization("client-id", "https://localhost:3000", ["scope1", "scope2"]);
const sdk = SpotifyApi.withUserAuthorization("client-id", "http://127.0.0.1:3000", ["scope1", "scope2"]);
const user = await sdk.currentUser.profile()
```

Expand All @@ -104,9 +104,9 @@ Setup:

*Client Side*
```js
SpotifyApi.performUserAuthorization("client-id", "https://localhost:3000", ["scope1", "scope2"], "https://your-backend-server.com/accept-user-token");
SpotifyApi.performUserAuthorization("client-id", "http://127.0.0.1:3000", ["scope1", "scope2"], "https://your-backend-server.com/accept-user-token");
// Alternatively if you want to perform your own custom post-back
SpotifyApi.performUserAuthorization("client-id", "https://localhost:3000", ["scope1", "scope2"], (accessToken) => { /* do postback here */ });
SpotifyApi.performUserAuthorization("client-id", "http://127.0.0.1:3000", ["scope1", "scope2"], (accessToken) => { /* do postback here */ });
```

These functions will work as usual, triggering a client side redirect to grant permissions, along with verifying the response and performing token exchange.
Expand Down Expand Up @@ -290,7 +290,7 @@ We provide a default browser (localStorage) caching strategy and (TODO) a node i

To run the tests, you need to have a Spotify account.

You will need to create a new app in the Spotify Developer portal, and add a redirect URI of `http://localhost:3000`.
You will need to create a new app in the Spotify Developer portal, and add a redirect URI of `http://127.0.0.1:3000`.

You will need to add the following environment variables:

Expand All @@ -308,6 +308,6 @@ We support `dotenv`, so you can add these to a `.env` file in the root of the re
To run the embedded example app, you will need to add the following environment variables:

- `VITE_SPOTIFY_CLIENT_ID`=the same value as set in INTEGRATION_TESTS_SPOTIFY_CLIENT_ID
- `VITE_REDIRECT_TARGET`=http://localhost:3000
- `VITE_REDIRECT_TARGET`=http://127.0.0.1:3000

For the example app to work, this .env file needs to be in the ./example folder.
2 changes: 1 addition & 1 deletion example/.env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_SPOTIFY_CLIENT_ID=your_spotify_client_id_for_tests
VITE_REDIRECT_TARGET=http://localhost:3000
VITE_REDIRECT_TARGET=http://127.0.0.1:3000
2 changes: 1 addition & 1 deletion example_react/.env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VITE_SPOTIFY_CLIENT_ID=your_spotify_client_id_for_tests
VITE_REDIRECT_TARGET=http://localhost:3000
VITE_REDIRECT_TARGET=http://127.0.0.1:3000
2 changes: 1 addition & 1 deletion example_react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export default defineConfig({
server: {
port: 3000,
strictPort: true,
host: true,
host: '127.0.0.1',
},
})
2 changes: 1 addition & 1 deletion src/SpotifyApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("SpotifyAPI Instance", () => {
});

it("can create an instance with the authorization code strategy configured", async () => {
const sut = SpotifyApi.withUserAuthorization("client-id", "https://localhost:3000", ["scope1", "scope2"]);
const sut = SpotifyApi.withUserAuthorization("client-id", "http://127.0.0.1:3000", ["scope1", "scope2"]);
expect(sut["authenticationStrategy"].constructor.name).toBe(AuthorizationCodeWithPKCEStrategy.name);
});

Expand Down
4 changes: 2 additions & 2 deletions src/test/AuthAsRealUserForTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class AuthAsSpecificUserForTests extends AuthorizationCodeWithPKC
private email: string,
private password: string
) {
super(clientId, "http://localhost:3000", scopes);
super(clientId, "http://127.0.0.1:3000", scopes);
this.cacheKey = `test-user-${email}`;
}

Expand Down Expand Up @@ -66,7 +66,7 @@ export default class AuthAsSpecificUserForTests extends AuthorizationCodeWithPKC
await page.waitForRequest(r => {
const url = r.url();
capturedUrl = url;
return url.includes("http://localhost:3000");
return url.includes("http://127.0.0.1:3000");
});
} catch (e) {
console.log(capturedUrl, e);
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
server: {
port: 3000,
strictPort: true,
host: true,
host: '127.0.0.1',
},
plugins: [],
test: {
Expand Down