dart flutter httpclient : authorization
7,666
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});
Author by
David
Updated on December 03, 2022Comments
-
David over 1 year
i would like to perform a basic authentication with a simple token; how to perform this in flutter? which is the best way?
var response = await httpClient.post(url, body: {'name': 'doodle', 'color': 'blue'});
is it sufficient to ad an authentication header, for example in this way ?
var response = await httpClient.post( url, header:{ 'authorization' : 'bearer $token', 'content-type':'application/json' }, body :{some body});
I'm using a JWT token type