{"id":64460,"date":"2025-05-03T17:43:16","date_gmt":"2025-05-03T09:43:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/64460\/"},"modified":"2025-05-03T17:43:16","modified_gmt":"2025-05-03T09:43:16","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-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/64460\/","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><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173062621682772.jpg\" class=\"aligncenter\" title=\"SpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f\u63d2\u56fe\" alt=\"SpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>hub\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\u5c06_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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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> \u767b\u5f55\u540e\u590d\u5236 <\/p>\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\/kuleky\/article\/details\/104217757)<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fSpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>hub\u6388\u6743\u767b\u5f55\u65e0\u6cd5\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\u7684\u89e3\u51b3\u65b9\u6cd5 \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 \u6388\u6743\u51ed\u8bc1\u4f20\u9012\u65b9\u5f0f\u4e0d\u6b63\u786e \u5728\u4f7f\u7528github\u7684api\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\u65f6\uff0c\u5e94\u5c06_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 authorization: bearer {access_token} \u767b\u5f55\u540e\u590d\u5236 \u5177\u4f53\u4fee\u6539\u65b9\u5f0f\u5982\u4e0b\uff1a HttpHeaders headers = new HttpHeaders(); headers.add(&#8220;Authorization&#8221;, &#8220;Bearer &#8221; + accessToken); ResponseEntity&lt;String&gt; response = template.getForEntity(GITHUB_USER_API, headers, String.class); \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0cgithub_user_api\u4e3agithub\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606fapi\u7684\u5730\u5740\u3002 \u53c2\u8003\uff1a [springboot github oauth2 \u767b\u5f55\u62ff\u4e0d\u5230\u7528\u6237\u4fe1\u606f\u95ee\u9898\u53ca\u89e3\u51b3](https:\/\/blog.csdn.net\/kuleky\/article\/details\/104217757) \u4ee5\u4e0a\u5c31\u662fSpringBoot\u9879\u76ee\u4f7f\u7528GitHub\u6388\u6743\u767b\u5f55\u65f6\uff0c\u5982\u4f55\u83b7\u53d6\u6388\u6743\u8d26\u53f7\u4fe1\u606f\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-64460","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=64460"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64460\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=64460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=64460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=64460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}