Announcements

Help Wizard

Step 1

NEXT STEP

Cannot get first authorization code

Cannot get first authorization code

Well, basically I am trying to start the authorization flow to get an accessToken to retrieve data from the authorized user.

 

The problem is that I am constantly getting `response_type must be code or token` with the code 400 - bad request.

 

The url I am reaching is this one: `https://accounts.spotify.com/authorize?respose_type=code&client_id=<my_client_id>&client_secret=<my_...

 

Obviously I am using the correct client_id and client_secret in the url.

 

This is happening when I create the URL using this code:

 

```ts

import env from '@configs/env';
import logger from '@configs/logger';
import { Response } from 'express';

const {
SPOTIFY_CLIENT_ID,
SPOTIFY_CLIENT_SECRET,
SPOTIFY_AUTHORIZE_URL,
REDIRECT_URI
} = env;

const getExchangeCode = (res: Response): void => {
const query = new URLSearchParams({
respose_type: 'code',
client_id: SPOTIFY_CLIENT_ID,
client_secret: SPOTIFY_CLIENT_SECRET,
scope: 'user-read-recently-played user-top-read playlist-modify-public',
redirect_uri: REDIRECT_URI
});

const url = new URL(SPOTIFY_AUTHORIZE_URL);
url.search = query.toString();

logger.info(url.toString());

res.redirect(url.toString());
};

export default getExchangeCode;

```

 

I doesn't work in both cases:

1. get redirected from my javascript app

2. access that same url manually

Reply
0 Replies

Suggested posts