{"id":10902,"date":"2022-09-24T10:03:16","date_gmt":"2022-09-24T02:03:16","guid":{"rendered":"https:\/\/blog.hoyo.idv.tw\/?p=10902"},"modified":"2022-09-25T00:57:39","modified_gmt":"2022-09-24T16:57:39","slug":"google-%e4%bd%bf%e7%94%a8-google-%e7%99%bb%e5%85%a5","status":"publish","type":"post","link":"https:\/\/blog.hoyo.idv.tw\/?p=10902","title":{"rendered":"Google - \u4f7f\u7528 Google \u767b\u5165"},"content":{"rendered":"<p>--<\/p>\n<h2>\u56e0\u70ba<\/h2>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-10905\" src=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2022\/09\/20220924-094112.png\" alt=\"\" width=\"936\" height=\"136\" srcset=\"https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2022\/09\/20220924-094112.png 936w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2022\/09\/20220924-094112-300x44.png 300w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2022\/09\/20220924-094112-768x112.png 768w, https:\/\/blog.hoyo.idv.tw\/wp-content\/uploads\/2022\/09\/20220924-094112-500x73.png 500w\" sizes=\"(max-width: 936px) 100vw, 936px\" \/><\/p>\n<p>\u6240\u4ee5\u8981\u66f4\u65b0<\/p>\n<p>--<\/p>\n<h2>\u53c3\u8003<\/h2>\n<ul>\n<li><a href=\"https:\/\/developers.google.com\/identity\/gsi\/web\/guides\/overview\" target=\"_blank\" rel=\"noopener\">\u7e3d\u89bd \u00a0|\u00a0 Sign In With Google \u00a0|\u00a0 Google Developers<\/a><\/li>\n<li><a href=\"https:\/\/developers.google.com\/identity\/gsi\/web\/tools\/configurator\" target=\"_blank\" rel=\"noopener\">\u751f\u6210HTML\u4ee3\u78bc| \u4f7f\u7528 Google \u767b\u9304 | \u8c37\u6b4c\u958b\u767c\u8005<\/a><\/li>\n<li><a href=\"https:\/\/developers.google.com\/identity\/gsi\/web\/guides\/handle-credential-responses-js-functions\" target=\"_blank\" rel=\"noopener\">\u4f7f\u7528 JavaScript \u51fd\u6578\u8655\u7406\u6191\u64da\u97ff\u61c9 \u00a0|\u00a0 Sign In With Google \u00a0|\u00a0 Google Developers<\/a><\/li>\n<\/ul>\n<p>--<\/p>\n<h2>\u61c9\u7528<\/h2>\n<ul>\n<li><a class=\"question-hyperlink\" href=\"https:\/\/stackoverflow.com\/questions\/68927855\/sign-in-with-google-console-log\" target=\"_blank\" rel=\"noopener\">Sign In with Google - Console.log<\/a><\/li>\n<\/ul>\n<p>\u4f7f\u7528\u8d77\u4f86\u66f4\u7c21\u55ae\u4e86\uff0c\u9019\u6a23\u5c31\u53ef\u4ee5\u4f7f\u7528 Google \u767b\u5165\u4e86\uff0c\u7576\u7136\u524d\u63d0\u662f\u5df2\u7d93\u6709\u7533\u8acb Google API \u4ee5\u53ca\u8a2d\u5b9a\u4e86\u76f8\u95dc\u7684\u91d1\u9470<\/p>\n<pre class=\"lang:default decode:true \">&lt;html&gt;\r\n&lt;body&gt;\r\n    &lt;script src=\"https:\/\/accounts.google.com\/gsi\/client\" async defer&gt;&lt;\/script&gt;\r\n    &lt;script src=\"https:\/\/unpkg.com\/jwt-decode\/build\/jwt-decode.js\"&gt;&lt;\/script&gt;\r\n    &lt;div id=\"g_id_onload\"\r\n         data-client_id=\"YOUR_GOOGLE_CLIENT_ID\"\r\n         data-callback=\"handleCredentialResponse\"&gt;\r\n    &lt;\/div&gt;\r\n    &lt;div class=\"g_id_signin\"\r\n        data-type=\"standard\"\r\n        data-size=\"large\"\r\n        data-theme=\"outline\"\r\n        data-text=\"sign_in_with\"\r\n        data-shape=\"rectangular\"\r\n        data-logo_alignment=\"left\"&gt;\r\n    &lt;\/div&gt;\r\n    &lt;script&gt;\r\n        function handleCredentialResponse(response) {\r\n            \/\/ decodeJwtResponse() is a custom function defined by you\r\n            \/\/ to decode the credential response.\r\n            const responsePayload = jwt_decode(response.credential);\r\n\r\n            console.log(\"ID: \" + responsePayload.sub);\r\n            console.log('Full Name: ' + responsePayload.name);\r\n            console.log('Given Name: ' + responsePayload.given_name);\r\n            console.log('Family Name: ' + responsePayload.family_name);\r\n            console.log(\"Image URL: \" + responsePayload.picture);\r\n            console.log(\"Email: \" + responsePayload.email);\r\n        }\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>--<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"10902\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;2,441&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>-- \u56e0\u70ba \u6240\u4ee5\u8981\u66f4\u65b0 -- ...<\/p>\n<div class=\"pvc_clear\"><\/div>\n<p class=\"pvc_stats all \" data-element-id=\"10902\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> &nbsp;2,441&nbsp;total views, &nbsp;1&nbsp;views today<\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[262],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/10902"}],"collection":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10902"}],"version-history":[{"count":7,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/10902\/revisions"}],"predecessor-version":[{"id":10912,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/10902\/revisions\/10912"}],"wp:attachment":[{"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hoyo.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}