{"id":526,"date":"2025-10-03T07:23:02","date_gmt":"2025-10-03T00:23:02","guid":{"rendered":"https:\/\/portal-atlasx.cdg.co.th\/home\/docs\/atlasx-api-gateway\/features\/authentication-with-oauth-2-0\/"},"modified":"2025-11-12T16:02:25","modified_gmt":"2025-11-12T09:02:25","slug":"authentication-with-oauth-2-0","status":"publish","type":"docs","link":"https:\/\/portal-atlasx.cdg.co.th\/home\/docs\/axgw\/features\/authentication-with-oauth-2-0\/","title":{"rendered":"API Gateway"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"api-gateway\">API Gateway<\/h1>\n\n\n\n<p>AtlasX API Gateway \u0e43\u0e0a\u0e49 Ocelot \u0e23\u0e48\u0e27\u0e21\u0e01\u0e31\u0e1a .NET 8 \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e43\u0e0a\u0e49\u0e40\u0e1b\u0e47\u0e19 Middleware \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a Reroute API request \u0e02\u0e2d\u0e07\u0e04\u0e38\u0e13\u0e44\u0e1b\u0e2b\u0e32 Microservice \u0e15\u0e48\u0e32\u0e07\u0e46 \u0e1a\u0e19 Server<\/p>\n\n\n\n<p>\u0e04\u0e38\u0e13\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e01\u0e32\u0e23 Reroute \u0e02\u0e2d\u0e07 Ocelot \u0e44\u0e14\u0e49\u0e1c\u0e48\u0e32\u0e19\u0e44\u0e1f\u0e25\u0e4c Configurations\/APIGateway\/ocelot-[Environment].json (ocelot.json \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a Production) \u0e42\u0e14\u0e22\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e02\u0e2d\u0e07\u0e44\u0e1f\u0e25\u0e4c config \u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e41\u0e2a\u0e14\u0e07\u0e44\u0e14\u0e49\u0e14\u0e31\u0e07\u0e19\u0e35\u0e49<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-Fira-Code\" style=\"font-size:.875rem;font-family:Code-Pro-Fira-Code,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span role=\"button\" tabindex=\"0\" style=\"color:#000000;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>{\n  \"$schema\": \"https:\/\/json.schemastore.org\/ocelot.json\",\n  \"Routes\": [\n    {\n      \"UpstreamHttpMethod\": [],\n      \"UpstreamPathTemplate\": \"\/api-gateway\/{everything}\",\n      \"DownstreamPathTemplate\": \"\/{everything}\",\n      \"DownstreamScheme\": \"http\",\n      \"DownstreamHostAndPorts\": &#91;\n        {\n          \"Host\": \"localhost\",\n          \"Port\": 5000\n        }\n      &#93;,\n      \"DangerousAcceptAnyServerCertificateValidator\": true\n    }\n  ]\n}<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki light-plus\" style=\"background-color: #FFFFFF\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #000000\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #A31515\">&quot;$schema&quot;<\/span><span style=\"color: #000000\">: <\/span><span style=\"color: #A31515\">&quot;https:\/\/json.schemastore.org\/ocelot.json&quot;<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  <\/span><span style=\"color: #A31515\">&quot;Routes&quot;<\/span><span style=\"color: #000000\">: [<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;UpstreamHttpMethod&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> [],<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;UpstreamPathTemplate&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;\/api-gateway\/{everything}&quot;<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;DownstreamPathTemplate&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;\/{everything}&quot;<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;DownstreamScheme&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;http&quot;<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;DownstreamHostAndPorts&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> &#91;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">          <\/span><span style=\"color: #A31515\">&quot;Host&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;localhost&quot;<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">          <\/span><span style=\"color: #A31515\">&quot;Port&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">5000<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      &#93;,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;DangerousAcceptAnyServerCertificateValidator&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">true<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">  ]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32-route\">\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32 Route<\/h2>\n\n\n\n<p>\u0e04\u0e38\u0e13\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e17\u0e33\u0e01\u0e32\u0e23\u0e40\u0e1e\u0e34\u0e48\u0e21 Route \u0e15\u0e48\u0e32\u0e07\u0e46 \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a redirect request \u0e02\u0e2d\u0e07\u0e04\u0e38\u0e13\u0e44\u0e1b\u0e22\u0e31\u0e07 Microservice \u0e17\u0e35\u0e48\u0e41\u0e15\u0e01\u0e15\u0e48\u0e32\u0e07\u0e01\u0e31\u0e19\u0e44\u0e14\u0e49\u0e43\u0e19 Array&nbsp;<strong>Routes<\/strong>&nbsp;\u0e42\u0e14\u0e22 property \u0e17\u0e35\u0e48\u0e04\u0e38\u0e13\u0e15\u0e49\u0e2d\u0e07\u0e23\u0e30\u0e1a\u0e38\u0e21\u0e35\u0e14\u0e31\u0e07\u0e19\u0e35\u0e49<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>UpstreamHttpMethod<\/code>\u00a0: \u0e23\u0e30\u0e1a\u0e38 HTTP Method \u0e17\u0e35\u0e48\u0e2d\u0e19\u0e38\u0e0d\u0e32\u0e15\u0e43\u0e2b\u0e49 reroute \u0e40\u0e0a\u0e48\u0e19 [ &#8220;POST&#8221;, &#8220;PUT&#8221;, &#8220;GET&#8221; ] \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e19 (\u0e2b\u0e23\u0e37\u0e2d\u0e1b\u0e25\u0e48\u0e2d\u0e22\u0e40\u0e1b\u0e47\u0e19 Array \u0e27\u0e48\u0e32\u0e07 \u0e16\u0e49\u0e32 allow \u0e17\u0e38\u0e01 method)<\/li>\n\n\n\n<li><code>UpstreamPathTemplate<\/code>\u00a0: \u0e23\u0e30\u0e1a\u0e38 template \u0e02\u0e2d\u0e07 URL path \u0e02\u0e32\u0e40\u0e02\u0e49\u0e32 (\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07 \/api-gateway\/{everything} \u0e08\u0e30\u0e23\u0e31\u0e1a Request \u0e08\u0e32\u0e01 http:\/\/{gateway-host}\/api-gateway\/{everything} \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e19)<\/li>\n\n\n\n<li><code>DownstreamPathTemplate<\/code>\u00a0: \u0e23\u0e30\u0e1a\u0e38 template \u0e02\u0e2d\u0e07 URL path \u0e02\u0e32\u0e2d\u0e2d\u0e01\u0e44\u0e1b\u0e22\u0e31\u0e07 Microservice \u0e1b\u0e25\u0e32\u0e22\u0e17\u0e32\u0e07 (\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07 \/{everything} \u0e08\u0e30 redirect \u0e17\u0e35\u0e48\u0e21\u0e32\u0e08\u0e32\u0e01 http:\/\/{gateway-host}\/api-gateway\/{everything} \u0e2a\u0e48\u0e07\u0e15\u0e48\u0e2d\u0e44\u0e1b\u0e22\u0e31\u0e07 http:\/\/{backend-host}\/{everything} \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e19)<\/li>\n\n\n\n<li><code>DownstreamScheme<\/code>\u00a0: \u0e23\u0e30\u0e1a\u0e38 Protocal \u0e02\u0e2d\u0e07 Backend (http \u0e2b\u0e23\u0e37\u0e2d https \u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e19)<\/li>\n\n\n\n<li><code>DownstreamHostAndPorts<\/code>\u00a0: \u0e23\u0e30\u0e1a\u0e38 Host \u0e41\u0e25\u0e30 Port \u0e02\u0e2d\u0e07 Backend \u0e17\u0e35\u0e48\u0e08\u0e30 Redirect \u0e44\u0e1b \u0e40\u0e0a\u0e48\u0e19 { &#8220;Host&#8221;: &#8220;localhost&#8221;, &#8220;Port&#8221;: 5000 } \u0e08\u0e30 redirect \u0e44\u0e1b\u0e2b\u0e32 Backend \u0e17\u0e35\u0e48\u00a0<a href=\"http:\/\/localhost:5000\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/localhost:5000<\/a>\u00a0\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e19<\/li>\n\n\n\n<li><code>DangerousAcceptAnyServerCertificateValidator<\/code>\u00a0: \u0e2b\u0e32\u0e01\u0e15\u0e31\u0e49\u0e07\u0e40\u0e1b\u0e47\u0e19 true \u0e08\u0e30\u0e17\u0e33\u0e43\u0e2b\u0e49 API Gateway \u0e44\u0e21\u0e48\u0e2a\u0e19\u0e43\u0e08 SSL Certificate \u0e02\u0e2d\u0e07 Request \u0e17\u0e35\u0e48\u0e40\u0e02\u0e49\u0e32\u0e21\u0e32 (\u0e44\u0e21\u0e48\u0e41\u0e19\u0e30\u0e19\u0e33\u0e43\u0e2b\u0e49\u0e43\u0e0a\u0e49\u0e1a\u0e19 Production)<\/li>\n<\/ul>\n\n\n\n<p>\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32\u0e2d\u0e37\u0e48\u0e19\u0e46 \u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e14\u0e39\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21\u0e44\u0e14\u0e49\u0e17\u0e35\u0e48&nbsp;<a href=\"https:\/\/ocelot.readthedocs.io\/en\/latest\/features\/configuration.html\" target=\"_blank\" rel=\"noreferrer noopener\">Ocelot Gateway Configuration<\/a><\/p>\n","protected":false},"featured_media":0,"parent":525,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"nav_title":"","positive":"","negative":"","footnotes":""},"docs_category":[],"class_list":["post-526","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/comments?post=526"}],"version-history":[{"count":2,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/526\/revisions"}],"predecessor-version":[{"id":3302,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/526\/revisions\/3302"}],"up":[{"embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/525"}],"wp:attachment":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/media?parent=526"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs_category?post=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}