3

Im trying to implement an Oauth1 login to garmins using Angular2 and regular http calls, but on the first call to oauth/request_token path i get a pre-flight OPTIONS call error seems not having CORS enabled or something.

It may anyone tried or did this before?

Thanks

Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54
bitgandtter
  • 2,179
  • 6
  • 31
  • 60
  • Are you familiar with CORS issues? – Jonathan M Mar 21 '17 at 18:50
  • https://en.wikipedia.org/wiki/Cross-origin_resource_sharing – Jonathan M Mar 21 '17 at 18:51
  • Which API url are you using for Garmin? – Jonathan M Mar 21 '17 at 18:54
  • @JonathanM im using http://connectapi.garmin.com/oauth-service-1.0/oauth/request_token as provided to us on the documentation. Yes im familiar with CORS issues and on this case the response for the OPTION call is not returning in the header the Access-Control-Allow-Origin key – bitgandtter Mar 21 '17 at 19:11
  • Hmmm. Can you post the response? – Jonathan M Mar 21 '17 at 19:18
  • The response was denied with code 501 Not Implemented, headers were Cache-Control:max-age=0, no-cache, no-store Connection:close Content-Length:317 Content-Type:text/html Date:Mon, 20 Mar 2017 22:44:48 GMT Expires:Mon, 20 Mar 2017 22:44:48 GMT Mime-Version:1.0 Pragma:no-cache Server:AkamaiGHost – bitgandtter Mar 21 '17 at 19:19
  • Which browser are you using? – Jonathan M Mar 21 '17 at 20:48
  • While it deals with a different framework, this answer could be enlightening: http://stackoverflow.com/questions/13814739/prototype-ajax-request-being-sent-as-options-rather-than-get-results-in-501-err#15300045 – Jonathan M Mar 21 '17 at 20:55
  • @JonathanM but this is not the case, since is an ajax request the pre-flight request OPTION will be trigger by the browser is not attach to any framework and the issue here seems to be that garmins server does not have the CORS enabled – bitgandtter Mar 21 '17 at 21:03
  • Do you have the text of the request? There may be elements in the request that are tripping up the server. – Jonathan M Mar 21 '17 at 21:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/138678/discussion-between-bitgandtter-and-jonathan-m). – bitgandtter Mar 21 '17 at 21:39
  • Is this public API ? if so please share the API docs link – All2Pie Oct 13 '21 at 06:15

1 Answers1

1

You have to set Origin in your header (my suggestion is to do it with an interceptor) and then in your server config allow your domain or localhost:port to access it.

Mahdi Zarei
  • 5,644
  • 7
  • 24
  • 54