Reputation: 217
I am making an react native android application in which in need to send client key and client secret to server.
const a = "ck_a332f4d89de6eed37b108f9eda13cfa1e71ce438";
const b = "cs_1c700d679d9613f507479325c1f53be4d3eac858";
const basicToken= base64.encode(a+ ':' +b);
componentDidMount(){
axios.get('http://link.com', {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': `Basic ${basicToken}` ,
//'consumer_key': "ck_a332f4d89de6eed37b108f9eda13cfa1e71ce438",
//'consumer_secret':"cs_1c700d679d9613f507479325c1f53be4d3eac858",
},
}).then((response) => response.json())
.then((responseJson) => {
ToastAndroid.show(JSON.stringify(responseJson),ToastAndroid.LONG)
}).catch((error) => {
console.error(error);
});
}
I have tried using both above code but it gives me 401 error.What i am doing wrong here? How can i send client key and secret to server using axios/fetch api
Upvotes: 0
Views: 773
Reputation: 191
As you have specified you are receiving an HTTP status code of 401. This implies you are unauthorized. You must log in with a valid user ID and password. Please cross check your token value.
Upvotes: 1