Spotify Implicit Grant Flow- Missing required parameter: client_id

javascript react-native spotify

475 观看


75 作者的声誉

I'm facing an issue that I don't understand! I am developing a react-native (js) app which try to access Spotify api using the Implicit Grant Flow.

Here is my method to get the access token:

async function getTokenFromAPI() {
    try {
        var params = {
            client_id: '<client_id>',
            response_type: 'token',
            redirect_uri: 'http://localhost:8888/callback'

        var esc = encodeURIComponent;
        var query = Object.keys(params)
            .map(k => `${esc(k)}=${esc(params[k])}`)

        fetch('', query).then(function (response) {
            console.log('response, ' + JSON.stringify(response));
            return response;
    } catch(error) {

but It answers that: Missing required parameter: client_id

I also used Postman to check if my request is good and I get the same response...

Is there something wrong? On their doc they tell that it is a GET method with only 3 parameters..

Thank you in advance for any workaround!

作者: Pierre-Louis Lacorte 的来源 发布者: 2017 年 9 月 15 日

回应 (1)


15040 作者的声誉


You are giving query parameters as options to fetch rather than adding it to the url.

change this

fetch('', query).then(function () { ... })

to this

fetch(`${query}`).then(function () { ... })
作者: bennygenel 发布者: 15.09.2017 11:01