api icon indicating copy to clipboard operation
api copied to clipboard

404 Error trying to exchange code for access token

Open georgdonner opened this issue 7 years ago • 3 comments

Hi there,

I'm trying to add the functionality to add lists to a Wunderlist account on my Angular app and managed to get to the point where I get the code back successfully. However, when trying to exchange that code for an access token, I get a 404 Not Found error. Making that exact same request with Postman works perfectly.

wunderlist.service.ts

import { Injectable } from '@angular/core';
import { Http, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import 'rxjs/add/operator/map';

@Injectable()
export class WunderlistService {

  constructor(private http: Http) { }

  getAccessToken(code: string) {
    var headers = new Headers();
    headers.append('Content-Type', 'application/json');
    return this.http.post('https://www.wunderlist.com/oauth/access_token', {
      "client_id": "myclientidhere",
      "client_secret": "myclientsecrethere",
      "code": JSON.stringify(code)
    }, {headers: headers})
    .map(res => res.json());
  }

}

And my error looks like this:

OPTIONS https://www.wunderlist.com/oauth/access_token 404 (Not Found)

XMLHttpRequest cannot load https://www.wunderlist.com/oauth/access_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:3000' is therefore not allowed access. The response had HTTP status code 404.

georgdonner avatar May 09 '17 15:05 georgdonner

Hi I am a getting the same error did you find any solution?

h27-webdev avatar Dec 26 '17 10:12 h27-webdev

I didn't pursue the idea to integrate with Wunderlist any further. But I guess the solution to the problem would be send a request to your own server. Then your server exchanges the code for the token and you send that back to your client (Angular). This way, you bypass the cross origin restrictions. I wish I would've known that back then ^^

georgdonner avatar Dec 27 '17 13:12 georgdonner

I have the same problem, can anyone help me?

razasultan avatar Jul 31 '20 18:07 razasultan