"refused to set unsafe header cookie" in Axios Request - axios

i'm trying to send cookie:
axios.get('https://localhost:44303/api/Home',{headers:{
"Accept": "application/json",
"Authorization": "Bearer " + localStorage.getItem("user"),
"Cache-Control": "no-cache",
'Cookie': document.cookie
// передача токена в заголовке
},credentials: "same-origin"}, ).
then(Response =>this.games=Response.data );
},
and i'm getting this error:
does anyone know how to solve this problem?

Related

flutter list payment paypal

i am trying to get a paypal payment list in flutter, but i can't get it.
This is the documentation:
doc paypal api
but I don't know where I'm wrong.
This is my code:
var response = await http.post(
Uri.parse(
"https://api-m.sandbox.paypal.com/v1/payments/payment?count=10&start_index=0&sort_by=create_time&sort_order=desc"),
headers: {
"content-type": "application/json",
'Authorization': 'Bearer ' + accessToken
});
I'm getting a 400's error: INVALID_REQUEST
a help? thank you
sorry for the nonsense I realized now that it is of type get and not post.
Correct code:
var response = await http.get(
Uri.parse(
"https://api-m.sandbox.paypal.com/v1/payments/payment?count=10&start_index=0&sort_by=create_time&sort_order=desc"),
headers: {
"content-type": "application/json",
'Authorization': 'Bearer ' + accessToken
});

Flutter web : Get with JSON body , doesnt work

I am unable to get this code working with Flutter web (it works in android+ios)
http.Request req = http.Request('GET', uri)
..body = json.encode(md)
..headers.addAll({
"Content-type": "application/json",
"Authorization": "Bearer ${token}",
"Access-Control-Allow-Origin": "*",
});
I checked fiddler output , body is missing . Any suggestions to get it working

what is the correct way to pass Bearer token in header section of my HTTP.Post in flutter

My Post API need a customer_id in body but also need a bearer token. I am passing it using following code
var myId="1005",
var token="my Token here"
var response = await http.post(Uri.parse("http://haulers.tech/jashn/mobile/home/shoutouttype"),
body: ({
"customer_id":myId.toString,
}),
headers: ({
"Authorisation": token.toString, //here I want to pass Bearer Token
})
);
This code return status code 401.
Pay attention to the word Bearer its must be Capitalized other ways it wont work, not sure whats the reason, but for flutter http calls make sure to capitalize that word like this
var response = await httpClient.post(
url,
headers:{
"Accept": "application/json",
"Content-type": "application/json",
"Authorization": "Bearer $token"
},
body :{some body});
Bearer tokens are usually sent preceded with Bearer : the following key value pair:-
"Authorization": "Bearer {TOKEN}"
Should work.

Can't delete files using a Dropbox Business team token

the following code should work, shouldn't it?
import requests
import json
url = "https://api.dropboxapi.com/2/files/delete_v2"
headers = {
"Authorization": "Bearer <access-token>",
"Content-Type": "application/json",
"Dropbox-Api-Select-Admin":
"dbmid:AADnRVGZHenLtFbLVdHDkqEJg3Dou4hWF4g"
}
data = {"path": "id:Kd_cXYig9pAAAAAAAAAARQ"}
print(requests.post(url, headers=headers, data=json.dumps(data)).content)
returns:
{"error_summary": "path_lookup/not_found/", "error": {".tag": "path_lookup", "path_lookup": {".tag": "not_found"}}}
Tried using Dropbox-Api-Select-User, and delete(v1) and permanently_delete and all failed with the same error.
FYI download worked.
(only with Select-Admin, but worked).
Thanks Greg.
Added "Dropbox-Api-Path-Root" header with the parent_shared_folder_id and the api call worked!
headers = {
"Authorization": "Bearer f7I8uYSFpxAAAAAAAAAFSs-VIz17DnoqmEYXp0MeitxIzXBCYCT4v0Bb4N4_cbxK",
"Content-Type": "application/json",
"Dropbox-Api-Path-Root": "{\".tag\": \"namespace_id\", \"namespace_id\": \"2857852064\"}",
"Dropbox-Api-Select-Admin": "dbmid:AADnRVGZHenLtFbLVdHDkqEJg3Dou4hWF4g"
}

Ionic Changes Content-Type

Ok I have to make a simple GET request that work in Postman but not in the Ionic code. I have determined that the reason is that the API treats incoming requests differently based on Content-Type. application/json works text doesn't.
headers: {
"Content-Type": 'application/json; charset=UTF-8',
"Accept": 'application/json; charset=UTF-8'
},
As you can see I'm setting the header to try to force application/json but when I sniff the request it has changed to text/html somehow. How do I force Ionic to take my Content-Type as definitive?
I managed to get it to work with the following headers
var headers = {
"Access-Control-Allow-Origin" : "*",
"Access-Control-Allow-Methods" : "POST, GET, OPTIONS, PUT",
"Content-Type": "application/json",
"Accept": "application/json"
};