{"id":203741,"date":"2025-05-22T14:42:55","date_gmt":"2025-05-22T06:42:55","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203741\/"},"modified":"2025-05-22T14:42:55","modified_gmt":"2025-05-22T06:42:55","slug":"springboot%e9%a1%b9%e7%9b%ae%e4%bd%bf%e7%94%a8github%e6%8e%88%e6%9d%83%e7%99%bb%e5%bd%95%e6%97%b6%ef%bc%8c%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96%e6%8e%88%e6%9d%83%e8%b4%a6%e5%8f%b7%e4%bf%a1%e6%81%af","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203741\/","title":{"rendered":"SpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>SpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f<\/h1>\n<p>\u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u5c31\u6574\u7406\u5206\u4eab\u300aSpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241120\/1732109633673de541df3b0.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>github\u6388\u6743\u767b\u5f55\u65e0\u6cd5\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\u7684\u89e3\u51b3\u65b9\u6cd5<\/strong><\/p>\n<p>\u5728\u8fdb\u884cspringboot\u9879\u76ee\u5f00\u53d1\u65f6\uff0c\u4f7f\u7528github\u6388\u6743\u767b\u5f55\u53ef\u80fd\u4f1a\u9047\u5230\u65e0\u6cd5\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\u7684\u95ee\u9898\u3002\u8fd9\u53ef\u80fd\u662f\u7531\u4e8e\u4ee5\u4e0b\u539f\u56e0\u9020\u6210\u7684\uff1a<\/p>\n<p><strong>\u6388\u6743\u51ed\u8bc1\u4f20\u9012\u65b9\u5f0f\u4e0d\u6b63\u786e<\/strong><\/p>\n<p>\u5728\u4f7f\u7528github\u7684api\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\u65f6\uff0c\u5e94\u5c06access_token\u4f5c\u4e3aauthorization http header\u4e2d\u7684\u53c2\u6570\u4f20\u8f93\uff0c\u800c\u4e0d\u662f\u4f5c\u4e3aurl\u4e2d\u7684\u53c2\u6570\u660e\u6587\u4f20\u8f93\u3002\u4ee5\u4e0b\u4e3a\u6b63\u786e\u7684\u8bf7\u6c42\u65b9\u5f0f\uff1a<\/p>\n<pre>authorization: bearer {access_token}<\/pre>\n<p>\u5177\u4f53\u4fee\u6539\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre>HttpHeaders headers = new HttpHeaders();\nheaders.add(\"Authorization\", \"Bearer \" + accessToken);\nResponseEntity&lt;String&gt; response = template.getForEntity(GITHUB_USER_API, headers, String.class);<\/pre>\n<p>\u5176\u4e2d\uff0cgithub_user_api\u4e3agithub\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606fapi\u7684\u5730\u5740\u3002<\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<ul>\n<li>[springboot github oauth2 \u767b\u5f55\u62ff\u4e0d\u5230\u7528\u6237\u4fe1\u606f\u95ee\u9898\u53ca\u89e3\u51b3](https:\/\/blog.csdn.net\/kuaileky\/article\/details\/104217757)<\/li>\n<\/ul>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300aSpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SpringBoot\u9879\u76ee\u4f7f\u7528Gi&#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-203741","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203741","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=203741"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203741\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}