microsoftarchive / api

The Wunderlist API Documentation
123 stars 37 forks source link

404 Error trying to exchange code for access token #117

Open georgdonner opened 7 years ago

georgdonner commented 7 years ago

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.

h27-webdev commented 6 years ago

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

georgdonner commented 6 years ago

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 ^^

razasultan commented 3 years ago

I have the same problem, can anyone help me?