{"id":208272,"date":"2025-07-08T12:21:12","date_gmt":"2025-07-08T04:21:12","guid":{"rendered":"https:\/\/server.hk\/cnblog\/208272\/"},"modified":"2025-07-08T12:21:12","modified_gmt":"2025-07-08T04:21:12","slug":"go-sdk%e4%bd%bf%e7%94%a8%e7%9a%84gcloud-auth%e8%b4%a6%e5%8f%b7","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/208272\/","title":{"rendered":"go sdk\u4f7f\u7528\u7684Gcloud auth\u8d26\u53f7"},"content":{"rendered":"<p><b><\/b> <\/p>\n<p>\u5f53\u524d\u4f4d\u7f6e\uff1a <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>&gt;<\/span> <span>go sdk\u4f7f\u7528\u7684Gcloud auth\u8d26\u53f7<\/span><\/p>\n<p><span>\u6765\u6e90\uff1astackoverflow<\/span><br \/>\n<span>2024-05-01 09:06:36<\/span><br \/>\n<span><i><\/i>0\u6d4f\u89c8<\/span><br \/>\n<span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span> <\/p>\n<p>\u5728IT\u884c\u4e1a\u8fd9\u4e2a\u53d1\u5c55\u66f4\u65b0\u901f\u5ea6\u5f88\u5feb\u7684\u884c\u4e1a\uff0c\u53ea\u6709\u4e0d\u505c\u6b62\u7684\u5b66\u4e60\uff0c\u624d\u4e0d\u4f1a\u88ab\u884c\u4e1a\u6240\u6dd8\u6c70\u3002\u5982\u679c\u4f60\u662fGolang\u5b66\u4e60\u8005\uff0c\u90a3\u4e48\u672c\u6587\u300ago sdk\u4f7f\u7528\u7684Gcloud auth\u8d26\u53f7\u300b\u5c31\u5f88\u9002\u5408\u4f60\uff01\u672c\u7bc7\u5185\u5bb9\u4e3b\u8981\u5305\u62ec##content_title##\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5b9e\u6218\u5f00\u53d1\uff01<\/p>\n<p> \u95ee\u9898\u5185\u5bb9<br \/>\n <\/p>\n<p>\u6211\u53ef\u7528\u7684 <code>gcloud<\/code> \u8eab\u4efd\u9a8c\u8bc1\u5e10\u6237\uff1a<\/p>\n<pre>\u25b6 gcloud auth list                                                        \n         Credentialed Accounts\nACTIVE  ACCOUNT\n        [email&nbsp;protected]\n        [email&nbsp;protected]\n*       [email&nbsp;protected]\n\nTo set the active account, run:\n    $ gcloud config set account `ACCOUNT`<\/pre>\n<p>\u5728\u6267\u884c <code>gcloud \u9879\u76ee list<\/code> \u65f6\uff0c\u6211<strong>\u786e\u5b9e<\/strong>\u83b7\u53d6\u4e0e\u4e0a\u9762\u6307\u793a\u4e3a\u201c\u6d3b\u52a8\u201d\u7684\u5e10\u6237\u5bf9\u5e94\u7684\u9879\u76ee\u5217\u8868\uff08\u5373\u5e26\u6709\u661f\u53f7\u7684\u9879\u76ee\uff0c<code>[email&nbsp;protected]<\/code>\uff09<\/p>\n<p>\u5c3d\u7ba1\u5982\u6b64\uff0c\u5f53\u6211\u4f7f\u7528 <code>go<\/code> google cloud sdk\uff08\u66f4\u5177\u4f53\u5730\u8bf4\u662f <code>cloudresourcemanager<\/code>\uff09\u6765\u5217\u51fa\u6211\u7684\u9879\u76ee\u65f6\uff0c\u6211\u4f1a\u5f97\u5230\u4e0e <code>[email&nbsp;protected]<\/code> \u5bf9\u5e94\u7684\u9879\u76ee\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48 go sdk \u4e0d\u4f7f\u7528 <code>gcloud<\/code> \u89c6\u4e3a\u6d3b\u52a8\u7684\u5e10\u6237\uff1f\u6211\u5982\u4f55\u6307\u793a\u5b83\u8fd9\u6837\u505a\uff1f<\/p>\n<p>\u5947\u602a\u7684\u662f\uff0c\u5f53\u6211\u4f7f\u7528 python sdk \u5f00\u53d1\u4e00\u4e9b\u5de5\u5177\u65f6\uff0c\u884c\u4e3a\u975e\u5e38\u7b80\u5355\uff0c\u5e76\u4e14\u6240\u6709 sdk \u8c03\u7528\u786e\u5b9e\u90fd\u5728\u4f7f\u7528\u6d3b\u52a8\u5e10\u6237\uff0c\u800c\u65e0\u9700\u6267\u884c\u4efb\u4f55\u989d\u5916\u7684\u914d\u7f6e\u6b65\u9aa4\u3002 <\/p>\n<p> <\/p>\n<h2>\u89e3\u51b3\u65b9\u6848<\/h2>\n<p> <\/p>\n<p>Google \u7684 [Golang] Cloud SDK \u9ed8\u8ba4\u4f7f\u7528 \u5bf9 Google Cloud Platforms \u670d\u52a1\u8fdb\u884c\u8eab\u4efd\u9a8c\u8bc1\u3002<\/p>\n<p>\u6211\u6000\u7591\uff08\uff01\uff09\u5728\u67d0\u4e2a\u65f6\u5019\uff0c\u60a8\u5c06 \u4e0e <code><\/code> \u4e00\u8d77\u4f7f\u7528\uff0c\u56e0\u6b64\u4f7f\u7528\u4e86\u6b64\u5e10\u6237\u3002<\/p>\n<p>\u6700\u4f73\u5b9e\u8df5\u662f\u5728 ADC \u4e2d\u4f7f\u7528\u670d\u52a1\u5e10\u6237\u800c\u4e0d\u662f\u4eba\u5de5\u5e10\u6237\uff0c\u7136\u540e\u4f7f\u7528 <code>GOOGLE_APPLICATION_CREDENTIALS<\/code> \u73af\u5883\u53d8\u91cf\u5f15\u7528\u8be5\u5e10\u6237\u3002<\/p>\n<p>\u540c\u65f6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4e0a\u8ff0\u547d\u4ee4\u5207\u6362\u5230 <code><\/code> \u6765\u786e\u8ba4\u884c\u4e3a\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8eGolang\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u524d\u4f4d\u7f6e\uff1a &gt; &gt; &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-208272","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=208272"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/208272\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=208272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=208272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=208272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}