Skip to content
This repository was archived by the owner on Jul 4, 2020. It is now read-only.
This repository was archived by the owner on Jul 4, 2020. It is now read-only.

No 'Access-Control-Allow-Origin' header is present on the requested resource. #616

@Klerith

Description

@Klerith

Hi, I'm trying to get the Token to do some api calls to the API, but I can't pass the "Access-Control-Allow-Origin" issue.

If I enable a Chrome plugins, all works fine, but if I turn it off, I get that error, by the way, I upload a demo to another website instead of localhost, but I got same error

I'm using Angular 2 and here's my call:

let headers = new Headers();
         headers.append('Content-Type', 'application/x-www-form-urlencoded');
         headers.append("cache-control", "no-cache");

        let body = new URLSearchParams();
        body.append('grant_type','client_credentials');
        body.append('client_id','XXXX');
        body.append('client_secret','XXXX');

        console.log( body.toString() ); // some check

        this.http.post( this.urlToken, body.toString() , { headers } )
              .subscribe( data=>{
                console.log(data);
          });

And this is the full error

XMLHttpRequest cannot load https://accounts.spotify.com/api/token. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

Endpoint(s):

All endpoints works with the token, but this is my only issue, get this token dynamically

Expected behaviour:

Get the access_token, token type and expires in.

I will appreciate any help, thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions