I’m learning ionic, my app should get data from my fitbit. I’ve set it upa as follows:
A node.js server (Server1) in my local machine, should get requests from the ionic app and do the authorization/callback loop with fitbit.
An ionic App, in development mode running on server 2 (CLI> ionic lab), making the requests to Server1.
On Server1 I’ve set up everything to allow CORS traffic (Access-Control-Allow-Origin etc…) and my communication between the ionic client and the server is OK.
fitbit requires a fixed callback after authorization (that’s the reason for Server1), so the first call from the ionic app triggers a server1-side “get” to the fitbit API, which goes back to the callback in Server1.
Thats the issue: When fitbit goes back to the callback URI the headers are “null” and the authorization is denied. I’ve tried also to go back to my ionic app after the first authorization request and then trigger from ionic a second request to the callback uri, but it’s not working. I get allways the following error:
XMLHttpRequest cannot load https://fitbit.com/oauth2/authorize?redirect_uri=<MY_HOST_AND SOME OIPTIONS>. Redirect from 'https://fitbit.com/oauth2/authorize?redirect_uri=<MY_HOST_AGAIN> to 'https://www.fitbit.com/oauth2/authorize?redirect_uri=<MY_HOST_THIRD_TIME> has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.