在Ajax中,如何为多个条件写"headers"?

in Ajax, how to write "headers" for multiple condition?

作为初学者,我在使用 Ajax(使用 Discogs API)时遇到了一些问题 .. 获取 discogs 请求令牌,discogs 说

Include the following headers with your request:
Content-Type: application/x-www-form-urlencoded
Authorization:
OAuth oauth_consumer_key="your_consumer_key",
oauth_nonce="random_string_or_timestamp",
oauth_signature="your_consumer_secret&",
oauth_signature_method="PLAINTEXT",
oauth_timestamp="current_timestamp",
oauth_callback="your_callback"
User-Agent: some_user_agent

https://www.discogs.com/developers#page:authentication,header:authentication-discogs-auth-flow

可是,这个header怎么写呢? 下面是我的尝试代码,但我知道这是不合适的。

$.ajax({
    type: "GET",
    url: "https://api.discogs.com/oauth/request_token",
    dataType: 'jsonp',
    headers: {
        ContentType: "application/x-www-form-urlencoded",
        Authorization: OAuth oauth_consumer_key="your_consumer_key",
            oauth_nonce="random_string_or_timestamp",
            oauth_signature="your_consumer_secret&",
            oauth_signature_method="PLAINTEXT",
            oauth_timestamp="current_timestamp",
            oauth_callback="your_callback",
        UserAgent: some_user_agent,
    }
    success: function (data) {
        console.log(data);
        document.getElementById("content").innerHTML += "<br>" + `${data}`;
    },
    error: function (error) {
        console.log(error);
    }
});

你说:

dataType: 'jsonp',

无法为 JSONP 请求指定 headers。

API 不能使用 JSONP。将数据类型设置为他们正在使用的格式。


文档说:

When you create a new application, you’ll be granted a Consumer Key and Consumer Secret, which you can plug into your application and start making authenticated requests. It’s important that you don’t disclose the Consumer Secret to anyone.

将它们放入您的 client-side 代码中会将它们透露给您的所有访问者。

应该从 server-side 代码.

向该端点发出请求