0

我已阅读此网站上的 OAuth 文档。

但是我仍然对请求 url 应该采用的格式感到困惑。

任何帮助都会很棒。

4

2 回答 2

0

您可以使用以下请求 url 来生成访问令牌,

String URL = "https://outpost.mapmyindia.com/api/security/oauth/token?grant_type=client_credentials&client_id="+clientid+"&client_secret="+clientsecret;

并且,在 POST 方法中添加以下标头,

(“接受”,“应用程序/json”)

(“内容类型”,“应用程序/x-www-form-urlencoded”)

如果您使用 Volley 库通过 POST 请求获取访问令牌,您可以将参数作为 HashMap 传递,如下所示:

Map<String, String> params = new HashMap<String, String>();
            params.put("accept", "application/json");
            params.put("Content-Type", "application/x-www-form-urlencoded");
于 2021-05-12T18:06:45.507 回答
0

看起来他们使用的是 Spring。它需要grant_type作为application/x-www-form-urlencoded. 以及标题中的凭据:

{
  'Authorization': `Basic ${base64Encode(clientId:clientSecret)}`,
}
于 2021-07-19T09:26:10.163 回答