Reputation: 465
I am having trouble accessing the Oxford Dictionary API. I keep getting the error:
'Authentication parameters missing'.
I believe I am not properly passing the api ID and key. I have referred to this documentation: https://developer.oxforddictionaries.com/documentation/making-requests-to-the-api https://developer.oxforddictionaries.com/documentation
Here is my code; trust me that the app id and key are the correct strings.
const url = 'https://od-api.oxforddictionaries.com/api/v1/entries/en/swim';
fetch(url, {
method: 'GET',
headers: new Headers({
'app_id': oxford.appId, 'app_key': oxford.appKey
}),
}).then(function(response) {
console.log(response);
});
Upvotes: 2
Views: 3656
Reputation: 465
I found an answer to my question here. Looks like the API does not support client side application requests. Guess I'll have to create a server.
Upvotes: 0
Reputation: 106
If the site looking for Authentication header it may refer to Basic Auth Header, read more here. If that is true, you simply can append your header parameter with this:
var headers = new Headers()
headers.append('Authorization', 'Basic ' + base64.encode(app_id + ":" + app_key));
You may try with or without the encoding.
You may also try this if that does not work
const url = 'https://od-api.oxforddictionaries.com/api/v1/entries/en/swim';
fetch(url, {
method: 'GET',
headers: { //HERE IS THE DIFFERENCE
'app_id': oxford.appId, 'app_key': oxford.appKey
},
mode: 'no-cors'
}).then(function(response) {
console.log(response);
});
If that does not work, another way to think of, it may be a CORS issue, you can read it more here
May this helps.
Upvotes: 2