如何在 UberRUSH 应用程序上设置 Origin URL

How to set Origin URL on a UberRUSH app

我需要使用 javascript 从浏览器直接从网络应用调用 UberRUSH API。 我已经创建了一个开发者帐户和一个设置为使用 UberRUSH 的应用程序,但在应用程序仪表板中我无法设置 Origin URI 以启用 CORS。

这是我遇到的错误:

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.

这不可以吗?我需要使用服务器作为代理吗?

我尝试了几种解决方案,但它们适用于游乐设施 API,您可以在游乐设施的仪表板中设置 Origin URI。例如

但没有任何效果。

这是我的代码:

$.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);
  }
})

The Rush API 目前不支持 CORS。