Flutter 코드북 - 예제) 인증 토큰 담아서 전송하기 (api, jwt)
api 토큰에 대한 인증은 정보를 헤더에 이렇게 담아서 진행하는데
final response = await http.get(
Uri.parse('https://jsonplaceholder.typicode.com/albums/1'),
headers: {
HttpHeaders.authorizationHeader: 'Basic your_api_token_here',
},
);
jwt 토큰은 헤더에 이렇게 해야한다.
final response = await http.get(
Uri.parse('http://3.38.70.153:8080/v1/playlist/${id}'),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer ${BlocProvider.of<UserCubit>(context).in_User!.jwt_token}',}
);
bearer는 JWT와 OAuth를 나타내는 인증 타입이다.
참고
https://docs.flutter.dev/cookbook
Cookbook
The Flutter cookbook provides recipes for many commonly performed tasks.
docs.flutter.dev
https://www.youtube.com/watch?v=_AcubBAsLI0
https://velog.io/@cada/토근-기반-인증에서-bearer는-무엇일까
토근 기반 인증에서 bearer는 무엇일까?
본 글은 MDN - HTTP 인증, Veloport님의 게시글을 참고하여 작성되었습니다. 자세하게 알고싶으신 분은 해당 링크를 참고해주세요.토큰 기반 인증인증 타입마치며토큰 기반 인증은 쿠키나 세션을 이
velog.io
https://stackoverflow.com/questions/58079131/bearer-token-request-http-flutter
Bearer token request http flutter
I need to send my token for my API. I save my token in SharedPreferences and I can recupered this. My API need one, with the Bearer but how do ? I tested with Authorization, Http etc. Methods To...
stackoverflow.com