{"id":118285,"date":"2025-08-14T15:35:30","date_gmt":"2025-08-14T08:35:30","guid":{"rendered":"https:\/\/tino.vn\/blog\/?p=118285"},"modified":"2025-08-14T15:35:58","modified_gmt":"2025-08-14T08:35:58","slug":"khac-phuc-loi-401-unauthorized-authorization-failed","status":"publish","type":"post","link":"https:\/\/tino.vn\/blog\/khac-phuc-loi-401-unauthorized-authorization-failed\/","title":{"rendered":"H\u01b0\u1edbng d\u1eabn kh\u1eafc ph\u1ee5c l\u1ed7i 401 Unauthorized (Authorization failed) khi g\u1ecdi API trong n8n"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Trong qu\u00e1 tr\u00ecnh x\u00e2y d\u1ef1ng automation v\u1edbi <a href=\"https:\/\/tino.vn\/blog\/n8n-la-gi\/\" target=\"_blank\" data-type=\"post\" data-id=\"104774\" rel=\"noreferrer noopener\">n8n<\/a>, nhi\u1ec1u ng\u01b0\u1eddi g\u1eb7p ph\u1ea3i l\u1ed7i 401 Unauthorized (Authorization failed) khi g\u1ecdi API, khi\u1ebfn workflow b\u1ecb gi\u00e1n \u0111o\u1ea1n v\u00e0 d\u1eef li\u1ec7u kh\u00f4ng th\u1ec3 l\u1ea5y ho\u1eb7c g\u1eedi th\u00e0nh c\u00f4ng. \u0110\u00e2y l\u00e0 m\u1ed9t l\u1ed7i th\u01b0\u1eddng xu\u1ea5t hi\u1ec7n khi th\u00f4ng tin x\u00e1c th\u1ef1c (Authentication) kh\u00f4ng h\u1ee3p l\u1ec7 ho\u1eb7c thi\u1ebfu quy\u1ec1n truy c\u1eadp. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n c\u00e1ch nh\u1eadn di\u1ec7n nguy\u00ean nh\u00e2n v\u00e0 kh\u1eafc ph\u1ee5c l\u1ed7i 401 Unauthorized (Authorization failed) trong n8n m\u1ed9t c\u00e1ch nhanh ch\u00f3ng.<\/strong><\/p>\n\n\n\n<h2 id=\"L\u1ed7i_401_Unauthorized_(Authorization_failed)_l\u00e0_g\u00ec?\"><a id=\"post-118285-_rj072vr2zj1c\"><\/a>L\u1ed7i 401 Unauthorized (Authorization failed) l\u00e0 g\u00ec?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">L\u1ed7i 401 Unauthorized (<strong>Authorization failed<\/strong>) l\u00e0 m\u1ed9t ph\u1ea3n h\u1ed3i HTTP th\u01b0\u1eddng g\u1eb7p khi g\u1ecdi API t\u1eeb n8n, cho bi\u1ebft y\u00eau c\u1ea7u c\u1ee7a b\u1ea1n b\u1ecb t\u1eeb ch\u1ed1i do thi\u1ebfu ho\u1eb7c sai th\u00f4ng tin x\u00e1c th\u1ef1c (authentication). Khi n8n g\u1eedi request \u0111\u1ebfn API nh\u01b0ng kh\u00f4ng cung c\u1ea5p \u0111\u00fang Authorization Header, API Key, token, username\/password (Basic Auth) ho\u1eb7c token \u0111\u00e3 h\u1ebft h\u1ea1n, m\u00e1y ch\u1ee7 s\u1ebd tr\u1ea3 v\u1ec1 m\u00e3 l\u1ed7i 401 k\u00e8m th\u00f4ng b\u00e1o <strong>Authorization failed<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"700\" height=\"375\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/khac-phuc-loi-401-unauthorized-authorization-failed-1.png\" alt=\"L\u1ed7i 401 Unauthorized (Authorization failed) l\u00e0 g\u00ec?\" class=\"wp-image-118295\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/khac-phuc-loi-401-unauthorized-authorization-failed-1.png 700w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/khac-phuc-loi-401-unauthorized-authorization-failed-1-300x161.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption class=\"wp-element-caption\"><strong>L\u1ed7i 401 Unauthorized (Authorization failed) l\u00e0 g\u00ec?<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Kh\u00e1c v\u1edbi l\u1ed7i 403 Forbidden (t\u1eeb ch\u1ed1i truy c\u1eadp d\u00f9 c\u00f3 x\u00e1c th\u1ef1c), l\u1ed7i 401 ch\u1ec9 ra r\u1eb1ng b\u1ea1n c\u1ea7n ki\u1ec3m tra l\u1ea1i c\u00e1ch th\u1ee9c authentication trong node <a href=\"https:\/\/tino.vn\/blog\/cach-them-api-vao-n8n\/\" target=\"_blank\" data-type=\"post\" data-id=\"104998\" rel=\"noreferrer noopener\">HTTP Request<\/a> (headers, query parameters) ho\u1eb7c l\u00e0m m\u1edbi token tr\u01b0\u1edbc khi th\u1eed l\u1ea1i. \u0110\u00e2y l\u00e0 l\u1ed7i ph\u1ed5 bi\u1ebfn khi t\u00edch h\u1ee3p API y\u00eau c\u1ea7u b\u1ea3o m\u1eadt ho\u1eb7c c\u00e1c d\u1ecbch v\u1ee5 \u0111\u00e1m m\u00e2y.<\/p>\n\n\n\n<h3 id=\"C\u00e1c_nguy\u00ean_nh\u00e2n_ch\u00ednh_g\u00e2y_ra_l\u1ed7i_401_Unauthorized\"><a id=\"post-118285-_l65hsgoj2tkx\"><\/a><strong>C\u00e1c nguy\u00ean nh\u00e2n ch\u00ednh g\u00e2y ra l\u1ed7i 401 Unauthorized<\/strong><\/h3>\n\n\n\n<h4 id=\"Sai_ho\u1eb7c_thi\u1ebfu_th\u00f4ng_tin_x\u00e1c_th\u1ef1c\"><a id=\"post-118285-_im0dv2gnoa3i\"><\/a>Sai ho\u1eb7c thi\u1ebfu th\u00f4ng tin x\u00e1c th\u1ef1c<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>API key, token, username\/password (Basic Auth) b\u1ecb nh\u1eadp sai.<\/li>\n\n\n\n<li>Qu\u00ean th\u00eam Authorization header (Bearer Token, API Key).<\/li>\n\n\n\n<li>Kh\u00f4ng b\u1eadt ch\u1ebf \u0111\u1ed9 authentication trong n\u00fat HTTP Request c\u1ee7a n8n.<\/li>\n<\/ul>\n\n\n\n<h4 id=\"Token_h\u1ebft_h\u1ea1n_ho\u1eb7c_b\u1ecb_thu_h\u1ed3i\"><a id=\"post-118285-_eqjztfb9cyd0\"><\/a>Token h\u1ebft h\u1ea1n ho\u1eb7c b\u1ecb thu h\u1ed3i<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Token OAuth 2.0\/JWT \u0111\u00e3 h\u1ebft th\u1eddi gian hi\u1ec7u l\u1ef1c.<\/li>\n\n\n\n<li>Token b\u1ecb thu h\u1ed3i do \u0111\u1ed5i m\u1eadt kh\u1ea9u ho\u1eb7c reset t\u1eeb ph\u00eda nh\u00e0 cung c\u1ea5p API.<\/li>\n<\/ul>\n\n\n\n<h4 id=\"Sai_ph\u01b0\u01a1ng_th\u1ee9c_x\u00e1c_th\u1ef1c\"><a id=\"post-118285-_5uczo18f1s3n\"><\/a>Sai ph\u01b0\u01a1ng th\u1ee9c x\u00e1c th\u1ef1c<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>API y\u00eau c\u1ea7u Bearer Token nh\u01b0ng l\u1ea1i d\u00f9ng Basic Auth (ho\u1eb7c ng\u01b0\u1ee3c l\u1ea1i).<\/li>\n\n\n\n<li>Nh\u1ea7m l\u1eabn gi\u1eefa API Key trong header v\u00e0 query parameter (v\u00ed d\u1ee5: ?api_key=XXX).<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"700\" height=\"375\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/khac-phuc-loi-401-unauthorized-authorization-failed-2.png\" alt=\"C\u00e1c nguy\u00ean nh\u00e2n ch\u00ednh g\u00e2y ra l\u1ed7i 401 Unauthorized\" class=\"wp-image-118296\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/khac-phuc-loi-401-unauthorized-authorization-failed-2.png 700w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/khac-phuc-loi-401-unauthorized-authorization-failed-2-300x161.png 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><figcaption class=\"wp-element-caption\"><strong>C\u00e1c nguy\u00ean nh\u00e2n ch\u00ednh g\u00e2y ra l\u1ed7i 401 Unauthorized<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<h4 id=\"Kh\u00f4ng_\u0111\u1ee7_quy\u1ec1n_(scope\/permissions)\"><a id=\"post-118285-_ydkoeeq72dfc\"><\/a>Kh\u00f4ng \u0111\u1ee7 quy\u1ec1n (scope\/permissions)<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Token c\u00f3 quy\u1ec1n h\u1ea1n h\u1ea1n ch\u1ebf, kh\u00f4ng \u0111\u1ee7 \u0111\u1ec3 truy c\u1eadp t\u00e0i nguy\u00ean.<\/li>\n\n\n\n<li>V\u00ed d\u1ee5: API c\u1ee7a GitHub y\u00eau c\u1ea7u scope repo nh\u01b0ng token ch\u1ec9 c\u00f3 quy\u1ec1n read:user.<\/li>\n<\/ul>\n\n\n\n<h4 id=\"L\u1ed7i_c\u1ea5u_h\u00ecnh_API_endpoint\"><a id=\"post-118285-_roowx381jgx8\"><\/a>L\u1ed7i c\u1ea5u h\u00ecnh API endpoint<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>URL API kh\u00f4ng ch\u00ednh x\u00e1c (v\u00ed d\u1ee5: g\u1ecdi api.example.com\/v1 thay v\u00ec api.example.com\/v2).<\/li>\n\n\n\n<li>Thi\u1ebfu Content-Type header (khi g\u1eedi JSON body).<\/li>\n<\/ul>\n\n\n\n<h4 id=\"API_y\u00eau_c\u1ea7u_x\u00e1c_th\u1ef1c_b\u1ed5_sung\"><a id=\"post-118285-_hubuci3dsnmx\"><\/a>API y\u00eau c\u1ea7u x\u00e1c th\u1ef1c b\u1ed5 sung<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>M\u1ed9t s\u1ed1 API c\u1ea7n IP whitelisting ho\u1eb7c 2FA (Two-Factor Authentication).<\/li>\n\n\n\n<li>V\u00ed d\u1ee5: Cloudflare API y\u00eau c\u1ea7u th\u00eam X-Auth-Email v\u00e0 X-Auth-Key.<\/li>\n<\/ul>\n\n\n\n<h4 id=\"L\u1ed7i_t\u1eeb_ph\u00eda_nh\u00e0_cung_c\u1ea5p_API\"><a id=\"post-118285-_d3nelrkeezsq\"><\/a>L\u1ed7i t\u1eeb ph\u00eda nh\u00e0 cung c\u1ea5p API<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>API \u0111ang b\u1ea3o tr\u00ec ho\u1eb7c c\u00f3 thay \u0111\u1ed5i v\u1ec1 authentication method.<\/li>\n\n\n\n<li>Rate limiting (qu\u00e1 nhi\u1ec1u request sai auth li\u00ean t\u1ee5c).<\/li>\n<\/ul>\n\n\n\n<h2 id=\"C\u00e1ch_kh\u1eafc_ph\u1ee5c_l\u1ed7i_L\u1ed7i_401_Unauthorized_(Authorization_failed)_l\u00e0_g\u00ec?_khi_g\u1ecdi_API_trong_n8n\"><a id=\"post-118285-_xd7pqp8o1bbo\"><\/a>C\u00e1ch kh\u1eafc ph\u1ee5c l\u1ed7i L\u1ed7i 401 Unauthorized (Authorization failed) l\u00e0 g\u00ec? khi g\u1ecdi API trong n8n<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>L\u01b0u \u00fd: <\/strong>B\u00e0i vi\u1ebft ch\u1ec9 gi\u1ea3 \u0111\u1ecbnh m\u1ed9t trong c\u00e1c nguy\u00ean nh\u00e2n k\u1ec3 tr\u00ean. B\u1ea1n c\u1ea7n x\u00e1c \u0111\u1ecbnh nguy\u00ean nh\u00e2n c\u1ee5 th\u1ec3 cho workflow c\u1ee7a m\u00ecnh.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 m\u1ed9t workflow n8n \u0111\u01a1n gi\u1ea3n s\u1eed d\u1ee5ng node HTTP Request \u0111\u1ec3 g\u1ecdi API OpenWeatherMap nh\u1eb1m l\u1ea5y th\u00f4ng tin th\u1eddi ti\u1ebft hi\u1ec7n t\u1ea1i c\u1ee7a m\u1ed9t th\u00e0nh ph\u1ed1. Workflow n\u00e0y gi\u1ea3 \u0111\u1ecbnh g\u1eb7p l\u1ed7i 401 Unauthorized do c\u1ea5u h\u00ecnh sai API Key. API n\u00e0y y\u00eau c\u1ea7u m\u1ed9t API Key h\u1ee3p l\u1ec7 \u0111\u01b0\u1ee3c truy\u1ec1n qua tham s\u1ed1 appid trong URL.<\/p>\n\n\n\n<h3 id=\"Gi\u1ea3_\u0111\u1ecbnh_workflow_m\u1eabu_b\u1ecb_l\u1ed7i_401\"><a id=\"post-118285-_jx5ypg5zs9o2\"><\/a><strong>Gi\u1ea3 \u0111\u1ecbnh workflow m\u1eabu b\u1ecb l\u1ed7i 401<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>B\u01b0\u1edbc 1: <\/strong>Truy c\u1eadp <a href=\"https:\/\/home.openweathermap.org\/api_keys\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/openweathermap.org\/api<\/a> v\u00e0 \u0111\u0103ng k\u00fd m\u1ed9t t\u00e0i kho\u1ea3n mi\u1ec5n ph\u00ed. Sau khi \u0111\u0103ng k\u00fd, b\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c m\u1ed9t API Key. Key n\u00e0y s\u1ebd \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 x\u00e1c th\u1ef1c c\u00e1c y\u00eau c\u1ea7u API c\u1ee7a b\u1ea1n. (<strong>L\u01b0u \u00fd: <\/strong>API Key m\u1edbi c\u00f3 th\u1ec3 m\u1ea5t m\u1ed9t th\u1eddi gian \u0111\u1ec3 k\u00edch ho\u1ea1t).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1285\" height=\"509\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-1.png\" alt=\"Gi\u1ea3 \u0111\u1ecbnh workflow m\u1eabu b\u1ecb l\u1ed7i 401\" class=\"wp-image-118286\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-1.png 1285w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-1-300x119.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-1-1024x406.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-1-768x304.png 768w\" sizes=\"(max-width: 1285px) 100vw, 1285px\" \/><figcaption class=\"wp-element-caption\"><strong>Gi\u1ea3 \u0111\u1ecbnh workflow m\u1eabu b\u1ecb l\u1ed7i 401<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>B\u01b0\u1edbc 2: <\/strong>T\u1ea1o m\u1ed9t workflow m\u1edbi trong n8n.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>B\u01b0\u1edbc 3: <\/strong>Th\u00eam node <strong>Trigger manually<\/strong>. \u0110\u00e2y th\u01b0\u1eddng l\u00e0 node kh\u1edfi \u0111\u1ea7u \u0111\u1ec3 b\u1ea1n test m\u1ed9t ch\u1ee9c n\u0103ng c\u1ee7a n8n.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>B\u01b0\u1edbc 4:<\/strong> Th\u00eam m\u1ed9t <strong>node HTTP Request<\/strong> v\u00e0o workflow v\u00e0 k\u1ebft n\u1ed1i n\u00f3 v\u1edbi node <strong>Trigger manually<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1214\" height=\"641\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-2.png\" alt=\"Gi\u1ea3 \u0111\u1ecbnh workflow m\u1eabu b\u1ecb l\u1ed7i 401\" class=\"wp-image-118287\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-2.png 1214w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-2-300x158.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-2-1024x541.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-2-768x406.png 768w\" sizes=\"(max-width: 1214px) 100vw, 1214px\" \/><figcaption class=\"wp-element-caption\"><strong>Gi\u1ea3 \u0111\u1ecbnh workflow m\u1eabu b\u1ecb l\u1ed7i 401<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>B\u01b0\u1edbc 5:<\/strong> C\u1ea5u h\u00ecnh node HTTP Request :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Method:<\/strong> Ch\u1ecdn <strong>GET<\/strong><\/li>\n\n\n\n<li><strong>URL: <\/strong>Nh\u1eadp <strong><code>https:\/\/api.openweathermap.org\/data\/2.5\/weather?q=hanoi<\/code><\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Nh\u01b0 v\u00e2y, URL tr\u00ean thi\u1ebfu ph\u1ea7n <strong>Query Parameters<\/strong> (bao g\u1ed3m <strong>&amp;appid=YOUR_API_KEY<\/strong>)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Khi b\u1ea1n th\u1ef1c thi workflow n\u00e0y, b\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c l\u1ed7i 401 Unauthorized. L\u00fd do l\u00e0 v\u00ec b\u1ea1n \u0111ang c\u1ed1 g\u1eafng truy c\u1eadp API m\u00e0 kh\u00f4ng cung c\u1ea5p API Key h\u1ee3p l\u1ec7.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1488\" height=\"884\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-3.png\" alt=\"Gi\u1ea3 \u0111\u1ecbnh workflow m\u1eabu b\u1ecb l\u1ed7i 401\" class=\"wp-image-118288\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-3.png 1488w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-3-300x178.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-3-1024x608.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-3-768x456.png 768w\" sizes=\"(max-width: 1488px) 100vw, 1488px\" \/><figcaption class=\"wp-element-caption\"><strong>Gi\u1ea3 \u0111\u1ecbnh workflow m\u1eabu b\u1ecb l\u1ed7i 401<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 id=\"Kh\u1eafc_ph\u1ee5c_l\u1ed7i_401_Unauthorized\"><a id=\"post-118285-_ottlhpi1xlcw\"><\/a><strong>Kh\u1eafc ph\u1ee5c l\u1ed7i 401 Unauthorized<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u0110\u1ec3 kh\u1eafc ph\u1ee5c l\u1ed7i n\u00e0y, ch\u00fang ta c\u1ea7n cung c\u1ea5p API Key h\u1ee3p l\u1ec7 th\u00f4ng qua tham s\u1ed1 appid .<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C\u1eadp nh\u1eadt node HTTP Request b\u1eb1ng c\u00e1ch b\u1ed5 sung th\u00eam ph\u1ea7n <strong>&amp;appid=YOUR_API_KEY<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;api.openweathermap.org\/data\/2.5\/weather?q=Hanoi&amp;appid=YOUR_API_KEY<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>L\u01b0u \u00fd: <\/strong>Thay th\u1ebf <strong>YOUR_API_KEY<\/strong> b\u1eb1ng API c\u1ee7a b\u1ea1n.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1507\" height=\"892\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-4.png\" alt=\"Kh\u1eafc ph\u1ee5c l\u1ed7i 401 Unauthorized\" class=\"wp-image-118289\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-4.png 1507w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-4-300x178.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-4-1024x606.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-4-768x455.png 768w\" sizes=\"(max-width: 1507px) 100vw, 1507px\" \/><figcaption class=\"wp-element-caption\"><strong>Kh\u1eafc ph\u1ee5c l\u1ed7i 401 Unauthorized<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Khi b\u1ea1n th\u1ef1c thi workflow \u0111\u00e3 \u0111\u01b0\u1ee3c s\u1eeda \u0111\u1ed5i, node HTTP Request s\u1ebd g\u1eedi y\u00eau c\u1ea7u v\u1edbi API Key h\u1ee3p l\u1ec7. L\u1ea7n n\u00e0y, y\u00eau c\u1ea7u s\u1ebd \u0111\u01b0\u1ee3c x\u00e1c th\u1ef1c th\u00e0nh c\u00f4ng v\u00e0 b\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c d\u1eef li\u1ec7u th\u1eddi ti\u1ebft cho H\u00e0 N\u1ed9i.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">K\u1ebft qu\u1ea3 l\u00e0 m\u1ed9t JSON ch\u1ee9a th\u00f4ng tin th\u1eddi ti\u1ebft t\u1ea1i H\u00e0 N\u1ed9i:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>coord &#8211; t\u1ecda \u0111\u1ed9 th\u00e0nh ph\u1ed1:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"lon\": 105.8412, \/\/ Kinh \u0111\u1ed9\n\n\"lat\": 21.0245 \/\/ V\u0129 \u0111\u1ed9<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>weather &#8211; m\u00f4 t\u1ea3 th\u1eddi ti\u1ebft:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"id\": 803, \/\/ M\u00e3 th\u1eddi ti\u1ebft\n\n\"main\": \"Clouds\", \/\/ Tr\u1eddi nhi\u1ec1u m\u00e2y\n\n\"description\": \"broken clouds\", \/\/ M\u00e2y r\u1ea3i r\u00e1c\n\n\"icon\": \"04d\" \/\/ Bi\u1ec3u t\u01b0\u1ee3ng (ng\u00e0y)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>main &#8211; th\u00f4ng s\u1ed1 ch\u00ednh:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"temp\": 304.55, \/\/ Nhi\u1ec7t \u0111\u1ed9 (Kelvin) \u2248 31.4\u00b0C\n\n\"feels_like\": 307.83, \/\/ C\u1ea3m gi\u00e1c nh\u01b0 34.7\u00b0C\n\n\"pressure\": 1004 \/\/ \u00c1p su\u1ea5t (hPa)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Ngo\u00e0i ra c\u00f2n nhi\u1ec1u th\u00f4ng s\u1ed1 kh\u00e1c b\u00ean d\u01b0\u1edbi.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">N\u1ebfu mu\u1ed1n hi\u1ec3n th\u1ecb \u0111\u1ed9 \u00b0C thay v\u1ecb \u0111\u1ed9 Kelvin, b\u1ea1n c\u00f3 th\u1ec3 b\u1ed5 sung thu\u1ed9c t\u00ednh<strong> &amp;units=metric <\/strong>v\u00e0o URL.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;api.openweathermap.org\/data\/2.5\/weather?q=Hanoi&amp;appid=YOUR_API_KEY&amp;units=metric<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1508\" height=\"877\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-5.png\" alt=\"Kh\u1eafc ph\u1ee5c l\u1ed7i 401 Unauthorized\" class=\"wp-image-118290\" title=\"\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-5.png 1508w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-5-300x174.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-5-1024x596.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2025\/08\/word-image-118285-5-768x447.png 768w\" sizes=\"(max-width: 1508px) 100vw, 1508px\" \/><figcaption class=\"wp-element-caption\"><strong>Kh\u1eafc ph\u1ee5c l\u1ed7i 401 Unauthorized<\/strong><\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h3 id=\"K\u1ebft_lu\u1eadn\"><a id=\"post-118285-_m24hm4nsr9g4\"><\/a><strong>K\u1ebft lu\u1eadn<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">401 Unauthorized khi g\u1ecdi API t\u1eeb n8n tuy g\u00e2y gi\u00e1n \u0111o\u1ea1n workflow nh\u01b0ng th\u01b0\u1eddng d\u1ec5 kh\u1eafc ph\u1ee5c n\u1ebfu b\u1ea1n hi\u1ec3u r\u00f5 nguy\u00ean nh\u00e2n. V\u1edbi v\u00ed d\u1ee5 workflow g\u1ecdi API trong b\u00e0i vi\u1ebft, hy v\u1ecdng b\u1ea1n \u0111\u00e3 n\u1eafm \u0111\u01b0\u1ee3c c\u00e1ch x\u1eed l\u00fd v\u00e0 ph\u00f2ng tr\u00e1nh l\u1ed7i n\u00e0y \u0111\u1ec3 quy tr\u00ecnh automation tr\u00ean n8n lu\u00f4n \u1ed5n \u0111\u1ecbnh v\u00e0 hi\u1ec7u qu\u1ea3. Ch\u00fac b\u1ea1n th\u00e0nh c\u00f4ng!<\/p>\n\n\n\n<h2 id=\"Nh\u1eefng_c\u00e2u_h\u1ecfi_th\u01b0\u1eddng_g\u1eb7p\"><a id=\"post-118285-_limibdp7conb\"><\/a>Nh\u1eefng c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p<\/h2>\n\n\n\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"T\u00f4i_n\u00ean_c\u1ea5u_h\u00ecnh_node_HTTP_Request_trong_n8n_nh\u01b0_th\u1ebf_n\u00e0o_\u0111\u1ec3_tr\u00e1nh_l\u1ed7i_401?\">T\u00f4i n\u00ean c\u1ea5u h\u00ecnh node HTTP Request trong n8n nh\u01b0 th\u1ebf n\u00e0o \u0111\u1ec3 tr\u00e1nh l\u1ed7i 401?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<ul class=\"wp-block-list\">\n<li>\u0110\u1ea3m b\u1ea3o URL ch\u1ee9a tham s\u1ed1 appid \u0111\u00fang.<\/li>\n\n\n\n<li>N\u1ebfu API y\u00eau c\u1ea7u header, th\u00eam v\u00e0o tab Headers (v\u00ed d\u1ee5: Authorization: Bearer your_valid_api_key_12345).<\/li>\n\n\n\n<li>Ki\u1ec3m tra ph\u01b0\u01a1ng th\u1ee9c x\u00e1c th\u1ef1c trong tab Credentials n\u1ebfu d\u00f9ng OAuth.<\/li>\n<\/ul>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"API_Key_trong_URL_hay_Header_th\u00ec_t\u1ed1t_h\u01a1n?\">API Key trong URL hay Header th\u00ec t\u1ed1t h\u01a1n?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">V\u1ec1 k\u1ef9 thu\u1eadt c\u1ea3 hai \u0111\u1ec1u \u0111\u01b0\u1ee3c, nh\u01b0ng Header an to\u00e0n h\u01a1n v\u00ec kh\u00f4ng hi\u1ec3n th\u1ecb API Key tr\u1ef1c ti\u1ebfp tr\u00ean URL, tr\u00e1nh b\u1ecb l\u1ed9 khi chia s\u1ebb workflow ho\u1eb7c log.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"T\u00f4i_\u0111\u00e3_nh\u1eadp_\u0111\u00fang_API_Key_nh\u01b0ng_v\u1eabn_b\u1ecb_401,_t\u1ea1i_sao?\">T\u00f4i \u0111\u00e3 nh\u1eadp \u0111\u00fang API Key nh\u01b0ng v\u1eabn b\u1ecb 401, t\u1ea1i sao?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">Nguy\u00ean nh\u00e2n c\u00f3 th\u1ec3 do:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Nh\u1eadp API Key \u1edf sai v\u1ecb tr\u00ed (URL, Header ho\u1eb7c Body kh\u00f4ng \u0111\u00fang y\u00eau c\u1ea7u c\u1ee7a API)<\/li>\n\n\n\n<li>API Key \u0111\u00e3 h\u1ebft h\u1ea1n ho\u1eb7c b\u1ecb thu h\u1ed3i<\/li>\n\n\n\n<li>Sai \u0111\u1ecbnh d\u1ea1ng Authorization Header<\/li>\n<\/ul>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section\t\thelp class=\"sc_fs_faq sc_card    \"\n\t\t\t\t>\n\t\t\t\t<h2 id=\"L\u00e0m_sao_\u0111\u1ec3_ki\u1ec3m_tra_xem_API_Key_c\u1ee7a_t\u00f4i_c\u00f3_ho\u1ea1t_\u0111\u1ed9ng_kh\u00f4ng?\">L\u00e0m sao \u0111\u1ec3 ki\u1ec3m tra xem API Key c\u1ee7a t\u00f4i c\u00f3 ho\u1ea1t \u0111\u1ed9ng kh\u00f4ng?<\/h2>\t\t\t\t<div>\n\t\t\t\t\t\t<div class=\"sc_fs_faq__content\">\n\t\t\t\t\n\n<p class=\"wp-block-paragraph\">B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00f4ng c\u1ee5 nh\u01b0 Postman ho\u1eb7c curl \u0111\u1ec3 g\u1eedi th\u1eed y\u00eau c\u1ea7u GET t\u1edbi endpoint OpenWeatherMap (v\u00ed d\u1ee5: https:\/\/api.openweathermap.org\/data\/2.5\/weather?q=Hanoi&amp;appid=your_api_key).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">N\u1ebfu nh\u1eadn \u0111\u01b0\u1ee3c d\u1eef li\u1ec7u JSON, API Key ho\u1ea1t \u0111\u1ed9ng. N\u1ebfu nh\u1eadn l\u1ed7i 401, h\u00e3y ki\u1ec3m tra l\u1ea1i API Key.<\/p>\n\n\t\t\t<\/div>\n\t\t<\/div>\n\t\t<\/section>\n\t\t\n<script type=\"application\/ld+json\">\n\t{\n\t\t\"@context\": \"https:\/\/schema.org\",\n\t\t\"@type\": \"FAQPage\",\n\t\t\"mainEntity\": [\n\t\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"T\u00f4i n\u00ean c\u1ea5u h\u00ecnh node HTTP Request trong n8n nh\u01b0 th\u1ebf n\u00e0o \u0111\u1ec3 tr\u00e1nh l\u1ed7i 401?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<ul><li>\u0110\u1ea3m b\u1ea3o URL ch\u1ee9a tham s\u1ed1 appid \u0111\u00fang.<\/li><li>N\u1ebfu API y\u00eau c\u1ea7u header, th\u00eam v\u00e0o tab Headers (v\u00ed d\u1ee5: Authorization: Bearer your_valid_api_key_12345).<\/li><li>Ki\u1ec3m tra ph\u01b0\u01a1ng th\u1ee9c x\u00e1c th\u1ef1c trong tab Credentials n\u1ebfu d\u00f9ng OAuth.<\/li><\/ul>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"API Key trong URL hay Header th\u00ec t\u1ed1t h\u01a1n?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>V\u1ec1 k\u1ef9 thu\u1eadt c\u1ea3 hai \u0111\u1ec1u \u0111\u01b0\u1ee3c, nh\u01b0ng Header an to\u00e0n h\u01a1n v\u00ec kh\u00f4ng hi\u1ec3n th\u1ecb API Key tr\u1ef1c ti\u1ebfp tr\u00ean URL, tr\u00e1nh b\u1ecb l\u1ed9 khi chia s\u1ebb workflow ho\u1eb7c log.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"T\u00f4i \u0111\u00e3 nh\u1eadp \u0111\u00fang API Key nh\u01b0ng v\u1eabn b\u1ecb 401, t\u1ea1i sao?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>Nguy\u00ean nh\u00e2n c\u00f3 th\u1ec3 do:<\/p><ul><li>Nh\u1eadp API Key \u1edf sai v\u1ecb tr\u00ed (URL, Header ho\u1eb7c Body kh\u00f4ng \u0111\u00fang y\u00eau c\u1ea7u c\u1ee7a API)<\/li><li>API Key \u0111\u00e3 h\u1ebft h\u1ea1n ho\u1eb7c b\u1ecb thu h\u1ed3i<\/li><li>Sai \u0111\u1ecbnh d\u1ea1ng Authorization Header<\/li><\/ul>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t,\t\t\t\t{\n\t\t\t\t\"@type\": \"Question\",\n\t\t\t\t\"name\": \"L\u00e0m sao \u0111\u1ec3 ki\u1ec3m tra xem API Key c\u1ee7a t\u00f4i c\u00f3 ho\u1ea1t \u0111\u1ed9ng kh\u00f4ng?\",\n\t\t\t\t\"acceptedAnswer\": {\n\t\t\t\t\t\"@type\": \"Answer\",\n\t\t\t\t\t\"text\": \"<p>B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng c\u00f4ng c\u1ee5 nh\u01b0 Postman ho\u1eb7c curl \u0111\u1ec3 g\u1eedi th\u1eed y\u00eau c\u1ea7u GET t\u1edbi endpoint OpenWeatherMap (v\u00ed d\u1ee5: https:\/\/api.openweathermap.org\/data\/2.5\/weather?q=Hanoi&amp;appid=your_api_key).<\/p><p>N\u1ebfu nh\u1eadn \u0111\u01b0\u1ee3c d\u1eef li\u1ec7u JSON, API Key ho\u1ea1t \u0111\u1ed9ng. N\u1ebfu nh\u1eadn l\u1ed7i 401, h\u00e3y ki\u1ec3m tra l\u1ea1i API Key.<\/p>\"\n\t\t\t\t\t\t\t\t\t}\n\t\t\t}\n\t\t\t\t\t\t]\n\t}\n<\/script>\n","protected":false},"excerpt":{"rendered":"<p>Trong qu\u00e1 tr\u00ecnh x\u00e2y d\u1ef1ng automation v\u1edbi n8n, nhi\u1ec1u ng\u01b0\u1eddi g\u1eb7p ph\u1ea3i l\u1ed7i 401 Unauthorized (Authorization failed) khi g\u1ecdi API, khi\u1ebfn workflow b\u1ecb gi\u00e1n \u0111o\u1ea1n v\u00e0 d\u1eef li\u1ec7u kh\u00f4ng th\u1ec3 l\u1ea5y ho\u1eb7c g\u1eedi th\u00e0nh c\u00f4ng. \u0110\u00e2y l\u00e0 m\u1ed9t l\u1ed7i th\u01b0\u1eddng xu\u1ea5t hi\u1ec7n khi th\u00f4ng tin x\u00e1c th\u1ef1c (Authentication) kh\u00f4ng h\u1ee3p l\u1ec7 ho\u1eb7c thi\u1ebfu quy\u1ec1n truy [&hellip;]<\/p>\n","protected":false},"author":23,"featured_media":118297,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7397],"tags":[7343],"class_list":["post-118285","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-n8n","tag-n8n"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/118285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=118285"}],"version-history":[{"count":1,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/118285\/revisions"}],"predecessor-version":[{"id":118298,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/posts\/118285\/revisions\/118298"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/118297"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=118285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/categories?post=118285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=118285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}