Search code examples
javascriptjqueryuber-api

How to set Origin URL on a UberRUSH app


I need to make calls to the UberRUSH API from a webapp directly from the browser using javascript. I've created a developer account and a app set to use UberRUSH, but in the app dashboard I can't set an Origin URI to enable CORS.

This is the error I'm getting:

XMLHttpRequest cannot load https://login.uber.com/oauth/v2/token.
Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'https://localhost:3000' is therefore not allowed access.

Is it not possible to do this? do I need to use the server as proxy?

I've tried several solutions, but they were meant for the Rides API, in which you can set a Origin URI in the dashboard. e.g

Does Uber API work with a local environment? Getting Access-Control-Allow-Origin issue on my https://localhost

Getting a "No 'Access-Control-Allow-Origin' header is present on the requested resource." Error

but nothing worked.

this is my code:

$.ajax({
  type: 'POST',
  url: 'https://login.uber.com/oauth/v2/token',
  contentType: 'x-www-form-urlencoded',
  data: {
    'client_id': '...my ID',
    'client_secret': 'my Secret',
    'grant_type': 'client_credentials',
    'scope': 'delivery_sandbox' // I've tried with 'delivery' as well
  },
  dataType: 'json',
  success: function(data){
    console.log('success')
    console.log(data);
    console.log(m);
  }
})

Solution

  • The Rush API does not support CORS at this time.