{"id":26654,"date":"2023-03-22T20:34:10","date_gmt":"2023-03-22T13:34:10","guid":{"rendered":"https:\/\/www.caodangvietmy.edu.vn\/?p=26654"},"modified":"2023-04-05T13:58:22","modified_gmt":"2023-04-05T06:58:22","slug":"laravel-socialite-tich-hop-xac-thuc-google-vao-website","status":"publish","type":"post","link":"https:\/\/www.caodangvietmy.edu.vn\/en\/laravel-socialite-tich-hop-xac-thuc-google-vao-website\/","title":{"rendered":"Laravel Socialite integrates Google authentication into websites."},"content":{"rendered":"<h2 style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u0110\u1eb7t v\u1ea5n \u0111\u1ec1<\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Hi\u1ec7n nay \u0111\u1ec3 c\u00f3 th\u1ec3 t\u1ea1o th\u00eam nhi\u1ec1u s\u1ef1 ti\u1ec7n l\u1ee3i cho ng\u01b0\u1eddi d\u00f9ng, c\u0169ng nh\u01b0 vi\u1ec7c gi\u00fap ng\u01b0\u1eddi d\u00f9ng kh\u00f4ng ph\u1ea3i t\u1ea1o qu\u00e1 nhi\u1ec1u t\u00e0i kho\u1ea3n v\u00e0 ph\u1ea3i nh\u1edb t\u1eebng account \u0111\u1ec3 truy c\u1eadp v\u00e0o t\u1eebng h\u1ec7 th\u1ed1ng. C\u00e1c \u1ee9ng d\u1ee5ng website \u0111\u00e3 t\u1ea1o ra nhi\u1ec1u ti\u1ec7n \u00edch cho vi\u1ec7c t\u1ea1o t\u00e0i kho\u1ea3n nh\u01b0 vi\u1ec7c b\u1ea1n c\u00f3 th\u1ec3 login b\u1eb1ng t\u00e0i kho\u1ea3n goole, facebook ho\u1eb7c github..vv. \u0110i\u1ec1u n\u00e0y kh\u00f4ng nh\u1eefng gi\u00fap cho ng\u01b0\u1eddi d\u00f9ng kh\u00f4ng c\u1ea7n m\u1ea5t th\u00eam th\u1eddi gian cho vi\u1ec7c t\u1ea1o 1 t\u00e0i kho\u1ea3n m\u1edbi v\u00e0 r\u1ed3i ph\u1ea3i nh\u1edb t\u1edbi n\u00f3 m\u1ed7i l\u00fac mu\u1ed1n \u0111\u0103ng nh\u1eadp v\u00e0o h\u1ec7 th\u1ed1ng.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Ngo\u00e0i ra t\u00edch h\u1ee3p c\u00e1c m\u1ea1ng x\u00e3 h\u1ed9i v\u00e0o ph\u1ea7n \u0111\u0103ng nh\u1eadp h\u1ec7 th\u1ed1ng website c\u00f3 nhi\u1ec1u c\u00e1c l\u1ee3i \u00edch nh\u01b0: Thu th\u1eadp th\u00eam th\u00f4ng tin ng\u01b0\u1eddi d\u00f9ng nh\u01b0 ng\u00e0y sinh, n\u01a1i sinh s\u1ed1ng, gi\u1edbi t\u00ednh&#8230; nh\u1eefng th\u00f4ng tin n\u00e0y ch\u00fang ta th\u01b0\u1eddng r\u00fat g\u1ecdn trong qu\u00e1 tr\u00ecnh \u0111\u0103ng k\u00fd t\u00e0i kho\u1ea3n. K\u1ebft h\u1ee3p v\u1edbi c\u00e1c h\u1ec7 th\u1ed1ng b\u00ecnh lu\u1eadn s\u1eed d\u1ee5ng m\u1ea1ng x\u00e3 h\u1ed9i r\u1ea5t thu\u1eadn ti\u1ec7n.<\/span><\/p>\n<h2 style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Laravel Socialite t\u00edch h\u1ee3p x\u00e1c th\u1ef1c Google v\u00e0o website<\/span><\/h2>\n<ol style=\"text-align: justify;\">\n<li><span style=\"font-family: 'times new roman', times, serif;\"><strong>M\u00f4 t\u1ea3 \u1ee9ng d\u1ee5ng<\/strong><\/span><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u0110\u1ea7u ti\u00ean m\u00ecnh s\u1ebd nh\u1ea5n n\u00fat \u0111\u0103ng nh\u1eadp google \u0111\u1ec3 login t\u00e0i kho\u1ea3n<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"1170\" height=\"470\" class=\"wp-image-26683\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-description-automaticall-1.png\" alt=\"Graphical user interface Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-description-automaticall-1.png 1170w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-description-automaticall-1-640x257.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-description-automaticall-1-1024x411.png 1024w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-description-automaticall-1-768x309.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-description-automaticall-1-430x173.png 430w\" sizes=\"(max-width: 1170px) 100vw, 1170px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Sau \u0111\u00f3 m\u00ecnh s\u1ebd ch\u1ecdn 1 t\u00e0i kho\u1ea3n google \u0111\u1ec3 \u0111\u0103ng nh\u1eadp trang web c\u1ee7a m\u00ecnh<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"480\" class=\"wp-image-26684\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/word-image-26654-2.png\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/word-image-26654-2.png 465w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/word-image-26654-2-252x260.png 252w\" sizes=\"(max-width: 465px) 100vw, 465px\" \/> <img loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"480\" class=\"wp-image-26685\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/word-image-26654-3.png\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/word-image-26654-3.png 465w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/word-image-26654-3-252x260.png 252w\" sizes=\"(max-width: 465px) 100vw, 465px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Sau khi \u0111\u0103ng nh\u1eadp xong th\u00ec trang web s\u1ebd chuy\u1ec3n t\u1edbi trang ch\u1ee7 v\u00e0 hi\u1ec3n th\u1ecb t\u00ean ng\u01b0\u1eddi d\u00f9ng \u1edf tr\u00ean thanh menu.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"1171\" height=\"488\" class=\"wp-image-26686\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-person-description-automaticall.png\" alt=\"A screenshot of a person Description automatically generated with medium confidence\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-person-description-automaticall.png 1171w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-person-description-automaticall-640x267.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-person-description-automaticall-1024x427.png 1024w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-person-description-automaticall-768x320.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-person-description-automaticall-430x179.png 430w\" sizes=\"(max-width: 1171px) 100vw, 1171px\" \/><\/span><\/p>\n<ol style=\"text-align: justify;\">\n<li><span style=\"font-family: 'times new roman', times, serif;\"><strong>Th\u1ef1c hi\u1ec7n<\/strong><\/span><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Sau \u0111\u00e2y l\u00e0 c\u00e1c b\u01b0\u1edbc \u0111\u1ec3 th\u1ef1c hi\u1ec7n \u0111\u0103ng nh\u1eadp v\u1edbi t\u00e0i kho\u1ea3n Google Api:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>B1: <\/strong>T\u1ea1o project laravel tr\u00ean cmd b\u1eb1ng d\u00f2ng l\u1ec7nh:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ composer create-project laravel\/laravel login-google<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"713\" height=\"392\" class=\"wp-image-26687\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-11.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-11.png 713w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-11-640x352.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-11-430x236.png 430w\" sizes=\"(max-width: 713px) 100vw, 713px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ cd login-google : \u0110\u1ec3 chuy\u1ec3n \u0111\u1ebfn folder login-google<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ php artisan serve : \u0110\u1ec3 ch\u1ea1y server<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"229\" class=\"wp-image-26688\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-12.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-12.png 882w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-12-640x166.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-12-768x199.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-12-430x112.png 430w\" sizes=\"(max-width: 882px) 100vw, 882px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ K\u1ebft qu\u1ea3 cu\u1ed1i s\u1ebd \u0111\u01b0\u1ee3c nh\u01b0 th\u1ebf n\u00e0y.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"1022\" height=\"556\" class=\"wp-image-26689\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-1.png\" alt=\"A screenshot of a computer Description automatically generated with medium confidence\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-1.png 1022w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-1-640x348.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-1-768x418.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-1-430x234.png 430w\" sizes=\"(max-width: 1022px) 100vw, 1022px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>B2: <\/strong>Ch\u1ec9nh migration user v\u00e0 ch\u1ea1y php artisan migrate \u0111\u1ec3 t\u1ea1o b\u1ea3ng users<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"924\" height=\"502\" class=\"wp-image-26690\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-2.png\" alt=\"A screenshot of a computer Description automatically generated with medium confidence\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-2.png 924w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-2-640x348.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-2-768x417.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-2-430x234.png 430w\" sizes=\"(max-width: 924px) 100vw, 924px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>B3: <\/strong>C\u00e0i \u0111\u1eb7t package Socialite \u0111\u1ec3 k\u1ebft n\u1ed1i v\u1edbi t\u00e0i kho\u1ea3n google b\u1eb1ng d\u00f2ng l\u1ec7nh<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">composer require laravel\/socialite<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"765\" height=\"480\" class=\"wp-image-26691\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-13.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-13.png 765w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-13-640x402.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-13-414x260.png 414w\" sizes=\"(max-width: 765px) 100vw, 765px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ Thi\u1ebft l\u1eadp th\u00f4ng s\u1ed1 cho Laravel Socialite<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Trong file config\/auth.php ta th\u00eam \u0111o\u1ea1n code socialite<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"643\" height=\"529\" class=\"wp-image-26692\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-14.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-14.png 643w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-14-640x527.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-14-316x260.png 316w\" sizes=\"(max-width: 643px) 100vw, 643px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Gi\u1edd \u0111\u1ebfn file config\/services.php thi\u1ebft l\u1eadp th\u00f4ng s\u1ed1 nh\u01b0 h\u00ecnh d\u01b0\u1edbi<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"509\" class=\"wp-image-26694\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-3.png\" alt=\"A screenshot of a computer Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-3.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-3-640x424.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/a-screenshot-of-a-computer-description-automatica-3-392x260.png 392w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>+ <\/strong>T\u1ea1i file .env ta khai b\u00e1o gi\u00e1 tr\u1ecb cho c\u00e1c tham s\u1ed1 client_id, client_secret, redirect qua c\u00e1c b\u01b0\u1edbc sau:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">B\u1ea1n v\u00e0o <a href=\"https:\/\/console.cloud.google.com\" rel=\"nofollow noopener\" target=\"_blank\">https:\/\/console.cloud.google.com<\/a>, th\u1ef1c hi\u1ec7n \u0111\u0103ng nh\u1eadp r\u1ed3i ch\u1ecdn CREATE IDENTIFIERS v\u00e0 ch\u1ecdn OAuth client ID<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"471\" class=\"wp-image-26696\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-application-description.png\" alt=\"Graphical user interface, application Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-application-description.png 776w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-application-description-640x388.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-application-description-768x466.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-application-description-428x260.png 428w\" sizes=\"(max-width: 776px) 100vw, 776px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Ti\u1ebfp theo b\u1ea1n \u1edf type of application ch\u1ecdn Web application v\u00e0 \u0111\u1eb7t t\u00ean cho api<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"667\" height=\"439\" class=\"wp-image-26698\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-email-description.png\" alt=\"Graphical user interface, text, email Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-email-description.png 667w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-email-description-640x421.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-email-description-395x260.png 395w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><em>T\u1ea1i Allowed redirect URIs ta th\u00eam \u0111\u01b0\u1eddng d\u1eabn ch\u1ee9 t\u00ean mi\u1ec1n c\u1ee7a b\u1ea1n k\u00e8m theo <\/em><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><em>\/ google\/callback gi\u1ed1ng trong h\u00ecnh <\/em><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"445\" height=\"363\" class=\"wp-image-26700\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-application-chat.png\" alt=\"Graphical user interface, text, application, chat or text message Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-application-chat.png 445w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-application-chat-319x260.png 319w\" sizes=\"(max-width: 445px) 100vw, 445px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Khi ch\u1ecdn create s\u1ebd tr\u1ea3 v\u1ec1 cho ch\u00fang ta 2 tr\u01b0\u1eddng n\u00e0y<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"637\" height=\"572\" class=\"wp-image-26702\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-application-email.png\" alt=\"Graphical user interface, text, application, email Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-application-email.png 637w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/graphical-user-interface-text-application-email-290x260.png 290w\" sizes=\"(max-width: 637px) 100vw, 637px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">Cu\u1ed1i c\u00f9ng v\u00e0o file .env t\u1ea1o 3 bi\u1ebfn gi\u1ed1ng trong h\u00ecnh r\u1ed3i sao ch\u00e9p 2 tr\u01b0\u1eddng tr\u00ean v\u00e0 Allowed redirect URIs v\u00e0o, v\u1eady l\u00e0 khai b\u00e1o xong c\u00e1c th\u00f4ng s\u1ed1 cho .env<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><img loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"513\" class=\"wp-image-26706\" src=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-15.png\" alt=\"Text Description automatically generated\" srcset=\"https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-15.png 895w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-15-640x367.png 640w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-15-768x440.png 768w, https:\/\/www.caodangvietmy.edu.vn\/wp-content\/uploads\/2023\/03\/text-description-automatically-generated-15-430x246.png 430w\" sizes=\"(max-width: 895px) 100vw, 895px\" \/><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>B4: <\/strong>T\u1ea1o Auth Login b\u1eb1ng c\u00e1c d\u00f2ng l\u1ec7nh<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ composer require laravel\/ui<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ php artisan ui bootstrap<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ php artisan ui bootstrap &#8211;auth<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">+ npm install &amp;&amp; npm run dev<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>B5: <\/strong>T\u1ea1i controller<strong>\u00a0app\/Http\/Controllers\/Auth\/LoginController.php\u00a0<\/strong>ta x\u1eed l\u00fd hai h\u00e0m<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">redirectToProvider: Chuy\u1ec3n h\u01b0\u1edbng ng\u01b0\u1eddi d\u00f9ng sang OAuth Provider<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">handleProviderCallback: L\u1ea5y th\u00f4ng tin t\u1eeb Provider, ki\u1ec3m tra n\u1ebfu ng\u01b0\u1eddi d\u00f9ng \u0111\u00e3 t\u1ed3n t\u1ea1i trong database th\u00ec \u0111\u0103ng nh\u1eadp, ng\u01b0\u1ee3c l\u1ea1i n\u1ebfu ch\u01b0a th\u00ec l\u01b0u ng\u01b0\u1eddi d\u00f9ng m\u1edbi v\u00e0o database.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">&lt;?php<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">namespace\u00a0<em>App\\Http\\Controllers\\Auth<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">use\u00a0<em>App\\Http\\Controllers\\Controller<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">use\u00a0<em>App\\Providers\\RouteServiceProvider<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">use\u00a0<em>Illuminate\\Foundation\\Auth\\AuthenticatesUsers<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">use\u00a0<em>Socialite<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">use\u00a0<em>App\\Models\\User<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">class\u00a0LoginController\u00a0extends\u00a0<em>Controller<\/em><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0use\u00a0<em>AuthenticatesUsers<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\/**<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0Where\u00a0to\u00a0redirect\u00a0users\u00a0after\u00a0login.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0@var\u00a0string<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0protected\u00a0$redirectTo\u00a0=\u00a0<em>RouteServiceProvider<\/em>::HOME;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\/**<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0Create\u00a0a\u00a0new\u00a0controller\u00a0instance.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*\u00a0@return\u00a0void<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0*\/<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0public\u00a0function\u00a0index()<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return\u00a0view(&#8216;frontend.form.login&#8217;);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0}<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0public\u00a0function\u00a0redirectToProvider($driver)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return\u00a0<em>Socialite<\/em>::driver($driver)-&gt;redirect();<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0}<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0public\u00a0function\u00a0handleProviderCallback($driver)<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0 try\u00a0{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$user\u00a0=\u00a0<em>Socialite<\/em>::driver($driver)-&gt;user();<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0 }\u00a0catch\u00a0(<em>\\Exception<\/em>\u00a0$e)\u00a0{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return\u00a0redirect()-&gt;route(&#8216;login&#8217;);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0}<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0$existingUser\u00a0=\u00a0<em>User<\/em>::where(&#8217;email&#8217;,\u00a0$user-&gt;getEmail())-&gt;first();<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0if\u00a0($existingUser)\u00a0{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0auth()-&gt;login($existingUser,\u00a0true);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0}\u00a0else\u00a0{<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$newUser\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0new\u00a0<em>User<\/em>;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$newUser-&gt;google_id\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0$user-&gt;id;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$newUser-&gt;name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0$user-&gt;name;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$newUser-&gt;password\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0$user-&gt;token;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$newUser-&gt;email\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\u00a0$user-&gt;email;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$newUser-&gt;email_verified_at\u00a0=\u00a0now();<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$newUser-&gt;save();<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0auth()-&gt;login($newUser,\u00a0true);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0}<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0\u00a0\u00a0\u00a0return\u00a0redirect(&#8216;\/&#8217;);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">}<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">}<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>+ B6: <\/strong>\u1edf routes\/web.php c\u00e1c b\u1ea1n reset l\u1ea1i route v\u00e0 th\u00eam route nh\u01b0 th\u1ebf n\u00e0y:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><em>Route<\/em>::get(&#8216;\/&#8217;,\u00a0[<em>App\\Http\\Controllers\\HomeController<\/em>::class,\u00a0&#8216;index&#8217;])-&gt;name(&#8216;home&#8217;);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><em>Route<\/em>::get(&#8216;login&#8217;,\u00a0[<em>App\\Http\\Controllers\\Auth\\LoginController<\/em>::class,\u00a0&#8216;index&#8217;])-&gt;name(&#8216;login&#8217;);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\/\/login\u00a0google<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><em>Route<\/em>::get(&#8216;redirect\/{driver}&#8217;,\u00a0[<em>App\\Http\\Controllers\\Auth\\LoginController<\/em>::class,\u00a0&#8216;redirectToProvider&#8217;])<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0-&gt;name(&#8216;login.provider&#8217;);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">\u00a0<em>Route<\/em>::get(&#8216;{driver}\/callback&#8217;,\u00a0[<em>App\\Http\\Controllers\\Auth\\LoginController<\/em>::class,\u00a0&#8216;handleProviderCallback&#8217;]);<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\"><strong>+ B7: <\/strong>T\u1ea1o giao di\u1ec7n \u0111\u0103ng nh\u1eadp ta t\u1ea1o li\u00ean k\u1ebft c\u00f3 d\u1ea1ng sau<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">&lt;button\u00a0<em>type<\/em>=&#8221;button&#8221;\u00a0<em>class<\/em>=&#8221;btn\u00a0btn-light&#8221;&gt;\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">&lt;a\u00a0<em>href<\/em>=&#8221;{{\u00a0route(&#8216;login.provider&#8217;,\u00a0&#8216;google&#8217;)\u00a0}}&#8221;&gt;\u0110\u0103ng\u00a0nh\u1eadp\u00a0google&lt;\/a&gt;\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">&lt;\/button&gt;<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: 'times new roman', times, serif;\">V\u1eady l\u00e0 v\u1edbi website \u0111\u01b0\u1ee3c x\u00e2y d\u1ef1ng b\u1eb1ng laravel framework b\u1ea1n c\u00f3 th\u1ec3 \u0111\u0103ng nh\u1eadp v\u1edbi google \u0111\u01b0\u1ee3c r\u1ed3i nha \u263a .<\/span><\/p>\n<p style=\"text-align: justify;\">\n","protected":false},"excerpt":{"rendered":"<p>Problem Statement: Currently, in order to create more convenience for users, and to help users avoid creating too many accounts and having to remember each account to access each system, website applications have created many useful features for account creation\u2026<\/p>","protected":false},"author":63,"featured_media":26686,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,877,851,626,850],"tags":[],"_links":{"self":[{"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/posts\/26654"}],"collection":[{"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/comments?post=26654"}],"version-history":[{"count":0,"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/posts\/26654\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/media\/26686"}],"wp:attachment":[{"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/media?parent=26654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/categories?post=26654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caodangvietmy.edu.vn\/en\/wp-json\/wp\/v2\/tags?post=26654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}