{"id":1187,"date":"2025-10-09T07:17:43","date_gmt":"2025-10-09T00:17:43","guid":{"rendered":"https:\/\/portal-atlasx.cdg.co.th\/home\/docs\/atlasx-web-service-v8-0\/features\/authentication-with-oauth-2-0\/"},"modified":"2026-03-27T09:01:01","modified_gmt":"2026-03-27T02:01:01","slug":"authentication-with-oauth-2-0","status":"publish","type":"docs","link":"https:\/\/portal-atlasx.cdg.co.th\/home\/docs\/axws\/features\/authentication-with-oauth-2-0\/","title":{"rendered":"Authentication with OAuth 2.0"},"content":{"rendered":"\n\n\n<p>AtlasX Web Service \u0e43\u0e0a\u0e49 OAuth 2.0 \u0e23\u0e48\u0e27\u0e21\u0e01\u0e31\u0e1a JWT \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23\u0e22\u0e37\u0e19\u0e22\u0e31\u0e19\u0e15\u0e31\u0e27\u0e15\u0e19<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e04\u0e48\u0e32<\/h2>\n\n\n\n<p>\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e04\u0e48\u0e32 OAuth \u0e43\u0e19&nbsp;<code>appsettings.json<\/code><\/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  \"App\": {\n    \"OAuth\": {\n      \"AccessTokenExpires\": 300,\n      \"RefreshTokenExpires\": 604800,\n      \"AuthorizationCodeExpires\": 300,\n      \"Issuer\": \"https:\/\/localhost:5001\",\n      \"SecretKey\": \"your-secret-key\",\n      \"MultiRefreshToken\": true,\n      \"VerifyCodeExpires\": 900\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;App&quot;<\/span><span style=\"color: #000000\">: {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">    <\/span><span style=\"color: #A31515\">&quot;OAuth&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;AccessTokenExpires&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">300<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;RefreshTokenExpires&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">604800<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;AuthorizationCodeExpires&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">300<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;Issuer&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;https:\/\/localhost:5001&quot;<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;SecretKey&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #A31515\">&quot;your-secret-key&quot;<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;MultiRefreshToken&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #0000FF\">true<\/span><span style=\"color: #000000\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #000000\">      <\/span><span style=\"color: #A31515\">&quot;VerifyCodeExpires&quot;<\/span><span style=\"color: #001080\">:<\/span><span style=\"color: #000000\"> <\/span><span style=\"color: #098658\">900<\/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<ol class=\"wp-block-list\">\n<li><code>Issuer<\/code>&nbsp;\u2014 URL \u0e02\u0e2d\u0e07 Authorization Server<\/li>\n\n\n\n<li><code>SecretKey<\/code>&nbsp;\u2014 key \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a sign JWT<\/li>\n\n\n\n<li><code>AccessTokenExpires<\/code>&nbsp;\u2014 \u0e2d\u0e32\u0e22\u0e38 Access Token (\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35)<\/li>\n\n\n\n<li><code>RefreshTokenExpires<\/code>&nbsp;\u2014 \u0e2d\u0e32\u0e22\u0e38 Refresh Token (\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35)<\/li>\n\n\n\n<li><code>AuthorizationCodeExpires<\/code>&nbsp;\u2014 \u0e2d\u0e32\u0e22\u0e38 Authorization Code (\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35)<\/li>\n\n\n\n<li><code>VerifyCodeExpires<\/code>&nbsp;\u2014 \u0e2d\u0e32\u0e22\u0e38 Verify Code (\u0e27\u0e34\u0e19\u0e32\u0e17\u0e35)<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Authentication Service Registration<\/h2>\n\n\n\n<p>\u0e25\u0e07\u0e17\u0e30\u0e40\u0e1a\u0e35\u0e22\u0e19 Authentication \u0e40\u0e02\u0e49\u0e32 DI container \u0e43\u0e19 <code>Program.cs<\/code><\/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:#D4D4D4;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>builder.Services.AddOAuth(builder.Configuration);\nbuilder.Services.AddAuth(builder.Configuration);<\/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 dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddOAuth<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Configuration<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddAuth<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Configuration<\/span><span style=\"color: #D4D4D4\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23 Endpoint \u0e17\u0e35\u0e48\u0e43\u0e2b\u0e49\u0e1a\u0e23\u0e34\u0e01\u0e32\u0e23<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h3 class=\"wp-block-heading\"><strong>AppLoginController<\/strong><\/h3>\n\n\n\n<p>\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e01\u0e32\u0e23 login \/ logout \u0e41\u0e25\u0e30\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23 session \u0e02\u0e2d\u0e07\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49\u0e1a\u0e19\u0e2b\u0e19\u0e49\u0e32\u0e40\u0e27\u0e47\u0e1a \u0e42\u0e14\u0e22\u0e21\u0e35\u0e23\u0e32\u0e22\u0e25\u0e30\u0e40\u0e2d\u0e35\u0e22\u0e14 \u0e14\u0e31\u0e07\u0e19\u0e35\u0e49<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>Method<\/strong><\/td><td><strong>Endpoint<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td>GET<\/td><td><code>\/config<\/code><\/td><td>\u0e14\u0e36\u0e07 application configuration \u0e08\u0e32\u0e01\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25<\/td><\/tr><tr><td>GET<\/td><td><code>\/login<\/code><\/td><td>\u0e41\u0e2a\u0e14\u0e07\u0e2b\u0e19\u0e49\u0e32 login \u0e16\u0e49\u0e32 login \u0e2d\u0e22\u0e39\u0e48\u0e41\u0e25\u0e49\u0e27\u0e08\u0e30 redirect \u0e44\u0e1b\u0e2b\u0e19\u0e49\u0e32\u0e2b\u0e25\u0e31\u0e01<\/td><\/tr><tr><td>POST<\/td><td><code>\/login<\/code><\/td><td>\u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a credentials \u0e2a\u0e23\u0e49\u0e32\u0e07 session \u0e41\u0e25\u0e30 set cookie<\/td><\/tr><tr><td>POST<\/td><td><code>\/logout<\/code><\/td><td>\u0e25\u0e1a session \u0e41\u0e25\u0e30 cookie \u0e41\u0e25\u0e49\u0e27\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e23\u0e30\u0e1a\u0e1a<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-group is-layout-flow wp-block-group-is-layout-flow\">\n<h3 class=\"wp-block-heading\"><strong>AuthenController<\/strong><\/h3>\n\n\n\n<p>OAuth 2.0 endpoints \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a login, token \u0e41\u0e25\u0e30\u0e01\u0e32\u0e23\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23 session<\/p>\n<\/div>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>Method<\/strong><\/td><td><strong>Endpoint<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td>GET<\/td><td><code>\/authen\/authorize<\/code><\/td><td>\u0e02\u0e2d Authorization Code (\u0e15\u0e49\u0e2d\u0e07 login \u0e01\u0e48\u0e2d\u0e19)<\/td><\/tr><tr><td>POST<\/td><td><code>\/authen\/token<\/code><\/td><td>\u0e41\u0e25\u0e01 Authorization Code \u0e2b\u0e23\u0e37\u0e2d Refresh Token \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e23\u0e31\u0e1a Access Token<\/td><\/tr><tr><td>GET<\/td><td><code>\/authen\/userinfo<\/code><\/td><td>\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 user \u0e08\u0e32\u0e01 Access Token (\u0e15\u0e49\u0e2d\u0e07\u0e21\u0e35 Bearer token)<\/td><\/tr><tr><td>POST<\/td><td><code>\/authen\/revoke<\/code><\/td><td>\u0e22\u0e01\u0e40\u0e25\u0e34\u0e01 token \u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e41\u0e25\u0e49\u0e27<\/td><\/tr><tr><td>GET<\/td><td><code>\/authen\/endsession<\/code><\/td><td>\u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01\u0e23\u0e30\u0e1a\u0e1a\u0e41\u0e25\u0e30\u0e25\u0e1a cookie \u0e1e\u0e23\u0e49\u0e2d\u0e21 redirect<\/td><\/tr><tr><td>POST<\/td><td><code>\/authen\/verify<\/code><\/td><td>\u0e2a\u0e48\u0e07 verification code \u0e1c\u0e48\u0e32\u0e19 email \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a register \u0e2b\u0e23\u0e37\u0e2d forget password<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">SessionService<\/h2>\n\n\n\n<p>\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23 session \u0e02\u0e2d\u0e07\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49\u0e42\u0e14\u0e22\u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e43\u0e19 distributed cache (Redis) session \u0e42\u0e14\u0e22\u0e41\u0e15\u0e48\u0e25\u0e30\u0e15\u0e31\u0e27\u0e08\u0e30\u0e16\u0e39\u0e01 identify \u0e14\u0e49\u0e27\u0e22&nbsp;<code>sessionId<\/code>&nbsp;\u0e17\u0e35\u0e48\u0e21\u0e35\u0e2d\u0e32\u0e22\u0e38\u0e41\u0e25\u0e30\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e2d\u0e32\u0e22\u0e38\u0e44\u0e14\u0e49<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SessionService Registration<\/h3>\n\n\n\n<p>\u0e01\u0e33\u0e2b\u0e19\u0e14\u0e04\u0e48\u0e32 SessionService \u0e43\u0e19 <code>Program.cs<\/code> \u0e42\u0e14\u0e22\u0e40\u0e1e\u0e34\u0e48\u0e21 Redis cache \u0e41\u0e25\u0e30 <code>SessionService<\/code> \u0e40\u0e02\u0e49\u0e32 DI container \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:#D4D4D4;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>builder.Services.AddCache(builder.Configuration.GetSection(\"Redis\")&#91;\"ConnectionString\"&#93;);\nbuilder.Services.AddScoped&lt;SessionService>();<\/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 dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddCache<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Configuration<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">GetSection<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #CE9178\">&quot;Redis&quot;<\/span><span style=\"color: #D4D4D4\">)&#91;<\/span><span style=\"color: #CE9178\">&quot;ConnectionString&quot;<\/span><span style=\"color: #D4D4D4\">&#93;);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9CDCFE\">builder<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #9CDCFE\">Services<\/span><span style=\"color: #D4D4D4\">.<\/span><span style=\"color: #DCDCAA\">AddScoped<\/span><span style=\"color: #D4D4D4\">&lt;<\/span><span style=\"color: #4EC9B0\">SessionService<\/span><span style=\"color: #D4D4D4\">&gt;();<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u0e08\u0e32\u0e01\u0e19\u0e31\u0e49\u0e19 inject&nbsp;<code>SessionService<\/code>&nbsp;\u0e40\u0e02\u0e49\u0e32 class \u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e01\u0e32\u0e23\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e1c\u0e48\u0e32\u0e19 constructor<\/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:#D4D4D4;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>public class MyService\n{\n    private readonly SessionService _session;\n\n    public MyService(SessionService session)\n    {\n        _session = session;\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 dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #9CDCFE\">public<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">class<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #4EC9B0\">MyService<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">private<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">readonly<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">SessionService<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">_session<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">public<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">MyService<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #9CDCFE\">SessionService<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">session<\/span><span style=\"color: #D4D4D4\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #9CDCFE\">_session<\/span><span style=\"color: #D4D4D4\"> = <\/span><span style=\"color: #9CDCFE\">session<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Methods<\/h3>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>Name<\/strong><\/td><td><strong>Returns<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td><code>CreateSession(String, SessionData, TimeSpan)<\/code><\/td><td><code>void<\/code><\/td><td>\u0e2a\u0e23\u0e49\u0e32\u0e07 session \u0e43\u0e2b\u0e21\u0e48\u0e41\u0e25\u0e30\u0e1a\u0e31\u0e19\u0e17\u0e36\u0e01\u0e25\u0e07\u0e43\u0e19 cache<\/td><\/tr><tr><td><code>GetSession(String)<\/code><\/td><td><code>SessionData?<\/code><\/td><td>\u0e14\u0e36\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25 session \u0e08\u0e32\u0e01 sessionId<\/td><\/tr><tr><td><code>RefreshSession(String, SessionData, TimeSpan)<\/code><\/td><td><code>void<\/code><\/td><td>\u0e2d\u0e31\u0e1b\u0e40\u0e14\u0e15\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e41\u0e25\u0e30\u0e15\u0e48\u0e2d\u0e2d\u0e32\u0e22\u0e38 session<\/td><\/tr><tr><td><code>RemoveSession(String)<\/code><\/td><td><code>void<\/code><\/td><td>\u0e25\u0e1a session \u0e2d\u0e2d\u0e01\u0e08\u0e32\u0e01 cache<\/td><\/tr><tr><td><code>RotateSession(String, SessionData, TimeSpan, TimeSpan)<\/code><\/td><td><code>string?<\/code><\/td><td>\u0e2a\u0e23\u0e49\u0e32\u0e07 session \u0e43\u0e2b\u0e21\u0e48\u0e41\u0e25\u0e30\u0e22\u0e01\u0e40\u0e25\u0e34\u0e01\u0e15\u0e31\u0e27\u0e40\u0e14\u0e34\u0e21<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Session Data<\/h3>\n\n\n\n<p>\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e40\u0e01\u0e47\u0e1a\u0e43\u0e19 session \u0e1b\u0e23\u0e30\u0e01\u0e2d\u0e1a\u0e14\u0e49\u0e27\u0e22<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td><strong>Field<\/strong><\/td><td><strong>Description<\/strong><\/td><\/tr><tr><td><code>UserId<\/code><\/td><td>ID \u0e02\u0e2d\u0e07\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49<\/td><\/tr><tr><td><code>Role<\/code><\/td><td>\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23 role \u0e02\u0e2d\u0e07\u0e1c\u0e39\u0e49\u0e43\u0e0a\u0e49<\/td><\/tr><tr><td><code>Permission<\/code><\/td><td>\u0e23\u0e32\u0e22\u0e01\u0e32\u0e23 permission \u0e43\u0e19\u0e23\u0e39\u0e1b\u0e41\u0e1a\u0e1a&nbsp;<code>roleId:functionId = view,edit<\/code><\/td><\/tr><tr><td><code>ExpiresAt<\/code><\/td><td>\u0e40\u0e27\u0e25\u0e32\u0e2b\u0e21\u0e14\u0e2d\u0e32\u0e22\u0e38\u0e02\u0e2d\u0e07 session<\/td><\/tr><tr><td><code>IsRotated<\/code><\/td><td>\u0e1a\u0e2d\u0e01\u0e27\u0e48\u0e32 session \u0e19\u0e35\u0e49\u0e16\u0e39\u0e01 rotate \u0e44\u0e1b\u0e41\u0e25\u0e49\u0e27\u0e2b\u0e23\u0e37\u0e2d\u0e22\u0e31\u0e07<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"featured_media":0,"parent":1186,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"nav_title":"","positive":"","negative":"","footnotes":""},"docs_category":[],"class_list":["post-1187","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/1187","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=1187"}],"version-history":[{"count":14,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/1187\/revisions"}],"predecessor-version":[{"id":4227,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/1187\/revisions\/4227"}],"up":[{"embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs\/1186"}],"wp:attachment":[{"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/media?parent=1187"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/portal-atlasx.cdg.co.th\/home\/wp-json\/wp\/v2\/docs_category?post=1187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}