{"id":3682,"date":"2019-01-07T10:59:25","date_gmt":"2019-01-07T02:59:25","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3682"},"modified":"2019-01-07T10:59:25","modified_gmt":"2019-01-07T02:59:25","slug":"webflux-%e7%bd%91%e7%ab%99%e5%be%ae%e4%bf%a1%e7%ac%ac%e4%b8%89%e6%96%b9%e7%99%bb%e5%bd%95","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3682","title":{"rendered":"WebFlux \u7f51\u7ad9\u5fae\u4fe1\u7b2c\u4e09\u65b9\u767b\u5f55"},"content":{"rendered":"<p>\n\t\u5fae\u4fe1\u7684\u5f3a\u793e\u4ea4\u5c5e\u6027\u8ba9\u5176\u62e5\u6709\u4f17\u591a\u7684\u7528\u6237\u3002\u4e00\u4e9b\u7b2c\u4e09\u65b9\u7f51\u7ad9\uff0c\u5982\u679c\uff0c\u6bcf\u4e2a\u90fd\u505a\u4e00\u5957\u7528\u6237\u7ba1\u7406\u7cfb\u7edf\uff0c\u8ba9\u6bcf\u4e2a\u7528\u6237\u90fd\u518d\u6ce8\u518c\u4e00\u904d\uff0c\u9996\u5148\u7ba1\u7406\u4e0a\u5c31\u9762\u4e34\u5f88\u591a\u95ee\u9898\u3002\u6bd4\u5982\uff0c\u8981\u4e0d\u8981\u53d1\u77ed\u4fe1\u9a8c\u8bc1\u7801\uff0c\u6d89\u53ca\u5230\u4fe1\u606f\u5b89\u5168\u7b49\u95ee\u9898\uff0c\u5c0f\u516c\u53f8\u5f88\u96be\u6709\u4fdd\u8bc1\u3002\u4e8e\u662f\u968f\u7740 OAuth \u7b49\u7b2c\u4e09\u65b9\u6388\u6743\u534f\u8bae\u7684\u53d1\u5c55\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5c0f\u7f51\u7ad9\u91c7\u7528\u7b2c\u4e09\u65b9\u6388\u6743\u767b\u5f55\u7684\u5f62\u5f0f\u5f00\u653e\u63a5\u5165\u7528\u6237\u7684\u884c\u4e3a\u3002\n<\/p>\n<p>\n\t\u57fa\u4e8e\u6b64\uff0c\u6211\u4eec\u5c31\u6765\u4f7f\u7528 WebFlux \u6765\u5b9e\u73b0\u4e00\u4e2a\u7f51\u7ad9\u63a5\u5165\u5fae\u4fe1\u3001QQ\u3001Github\u7b49\u7b2c\u4e09\u65b9\u767b\u5f55\u5427\uff01\n<\/p>\n<p>\n\t\u7fa4\u91cc\u6709\u5f88\u591a\u7f51\u53cb\u8ba9\u6211\u7ed9\u4ed6\u4eec\u505a\u4e00\u4e2a\u7f51\u7ad9\u63a5\u5165\u5fae\u4fe1\u767b\u5f55\u7684 demo\uff0c\u5e76\u613f\u610f\u51fa\u94b1\u8d2d\u4e70\uff01\u6ca1\u60f3\u5230\u5927\u5bb6\u6709\u8fd9\u4e48\u8feb\u5207\u7684\u9700\u6c42\uff0c\u4e8e\u662f\u5c31\u6709\u4e86\u672c\u6587\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u7f51\u7ad9\u63a5\u5165\u5fae\u4fe1\u626b\u7801\u767b\u5f55\u6548\u679c\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1fyxta587yxj20is07yq4m.jpg\" style=\"width: 676px;height: 286px\" \/>\n<\/p>\n<p>\n\t\u7f51\u7ad9\u5b9e\u73b0\u5fae\u4fe1\u7b2c\u4e09\u65b9\u767b\u5f55\u662f\u975e\u5e38\u7684\u7b80\u5355\u7684\u3002\u5171\u6709\u4e24\u79cd\u65b9\u5f0f\u6765\u5b9e\u73b0\u3002\n<\/p>\n<p>\n\t\u7b2c\u4e00\u79cd\u65b9\u5f0f\u662f\u7f51\u7ad9\u5d4c\u5165\u5fae\u4fe1\u626b\u7801\u767b\u5f55\u7684\u4e8c\u7ef4\u7801\u3002\u5b9e\u73b0\u8d77\u6765\u975e\u5e38\u7684\u7b80\u5355\uff0c\u9700\u8981\u5f15\u5165 http:\/\/res.wx.qq.com\/connect\/zh_CN\/htmledition\/js\/wxLogin.js \u6587\u4ef6\u3002\u7136\u540e\u521b\u5efa\u4e00\u4e2a WxLogin \u5bf9\u8c61\u3002\u5177\u4f53\u4ee3\u7801\u5982\u4e0b\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html lang=&quot;en&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;\/&gt;\r\n    &lt;title&gt;\u5fae\u4fe1\u767b\u5f55&lt;\/title&gt;\r\n    &lt;script src=&quot;http:\/\/res.wx.qq.com\/connect\/zh_CN\/htmledition\/js\/wxLogin.js&quot; \r\n    type=&quot;text\/javascript&quot;&gt;&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;div id=&quot;login_container&quot;&gt;\r\n&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n&lt;script&gt;\r\n    var obj = new WxLogin({\r\n        self_redirect:true,\r\n        id:&quot;login_container&quot;,\r\n        appid: &quot;wxbdc5610cc59c1631&quot;,\r\n        scope: &quot;snsapi_login&quot;,\r\n        redirect_uri: &quot;https%3A%2F%2Fpassport.yhd.com%2Fwechat%2Fcallback.do&quot;,\r\n        state: &quot;3d6be0a4035d839573b04816624a415e&quot;,\r\n        style: &quot;&quot;,\r\n        href: &quot;&quot;\r\n    });\r\n&lt;\/script&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\n\tWxLogin \u5bf9\u8c61\u7684\u53c2\u6570\u8bf4\u660e\u5982\u4e0b\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u5fae\u4fe1\u767b\u5f55 WxLogin \u5bf9\u8c61\u53c2\u6570\u8bf4\u660e\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1fyxtv0xr67j20ok0cp76i.jpg\" style=\"width: 884px;height: 457px\" \/>\n<\/p>\n<p>\n\t\u8fd8\u6709\u4e00\u79cd\u5b9e\u73b0\u65b9\u5f0f\u5c31\u662f\u7b2c\u4e09\u65b9\u4f7f\u7528\u7f51\u7ad9\u5e94\u7528\u6388\u6743\u767b\u5f55\u524d\uff0c\u5c06\u767b\u5f55\u8bf7\u6c42\u91cd\u5b9a\u5411\u5230 https:\/\/open.weixin.qq.com\/connect\/qrconnect?appid=APPID&amp;redirect_uri=REDIRECT_URI&amp;response_type=code&amp;scope=SCOPE&amp;state=STATE#wechat_redirect \u5730\u5740\u3002\n<\/p>\n<p>\n\t\u4e0a\u9762\u7684\u5404\u4e2a\u53c2\u6570\u89e3\u91ca\u8bf4\u660e\u5982\u4e0b\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u5fae\u4fe1\u6388\u6743\u767b\u5f55\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1fyxtxwy4m4j20nv08nq44.jpg\" style=\"width: 859px;height: 311px\" \/>\n<\/p>\n<p>\n\t\u5177\u4f53\u7684\u5b9e\u73b0\u4ee3\u7801\uff0c\u770b\u4e0b\u9762\u7684\u5b9e\u4f8b\uff1a\n<\/p>\n<pre class=\"brush:java;\">\r\n@Configuration\r\npublic class OAuthWeixinRouter {\r\n    @Autowired\r\n    private WeixinHandler weixinHandler;\r\n    @Bean\r\n    RouterFunction&lt;ServerResponse&gt; routerFunction() {\r\n        return RouterFunctions.route(RequestPredicates.GET(&quot;\/redirect&quot;), \r\n        weixinHandler::loginUrl);\r\n    }\r\n}\r\n@Component\r\npublic class WeixinHandler {\r\n    public Mono&lt;ServerResponse&gt; loginUrl(ServerRequest serverRequest) {\r\n        String TargetUrl = &quot;https:\/\/open.weixin.qq.com\/connect\/qrconnect?&quot; +\r\n                &quot;appid=wxbdc5610cc59c1631&quot; +\r\n                &quot;&amp;redirect_uri=https%3A%2F%2Fpassport.yhd.com%2Fwechat%2Fcallback.do&quot; +\r\n                &quot;&amp;response_type=code&amp;scope=snsapi_login&quot; +\r\n                &quot;&amp;state=3d6be0a4035d839573b04816624a415e#wechat_redirect&quot;;\r\n        return ServerResponse.temporaryRedirect(URI.create(TargetUrl)).build();\r\n    }\r\n}<\/pre>\n<p>\n\t\u9700\u8981\u6e90\u7801\u7684\u53ef\u4ee5\u52a0\u6211\u5fae\u4fe1\uff0c\u514d\u8d39\u83b7\u53d6\uff01\n<\/p>\n<p>\n\t\u7528\u6237\u5141\u8bb8\u6388\u6743\u540e\uff0c\u5c06\u4f1a\u91cd\u5b9a\u5411\u5230 redirect_uri \u7684\u7f51\u5740\u4e0a\uff0c\u5e76\u4e14\u5e26\u4e0a code \u548c state \u53c2\u6570\u3002\u82e5\u7528\u6237\u7981\u6b62\u6388\u6743\uff0c\u5219\u91cd\u5b9a\u5411\u540e\u4e0d\u4f1a\u5e26\u4e0a code \u53c2\u6570\uff0c\u4ec5\u4f1a\u5e26\u4e0a state \u53c2\u6570\u3002\n<\/p>\n<p>\n\t\u83b7\u5f97 code \u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 code \u83b7\u53d6 access_token\u3002\u7136\u540e\u6839\u636e access_token \u5c31\u53ef\u4ee5\u83b7\u53d6\u767b\u5f55\u7528\u6237\u7684\u5404\u79cd\u4fe1\u606f\u4e86\u3002\n<\/p>\n<h2>\n\t\u53c2\u8003\u8d44\u6599<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t<a href=\"https:\/\/oauth.net\/2\/\" name=\"OAuth 2.0\" target=\"_blank\" title=\"OAuth 2.0\">https:\/\/oauth.net\/2\/<\/a>\n\t<\/li>\n<li>\n\t\t<a href=\"https:\/\/open.weixin.qq.com\/cgi-bin\/showdocument?action=dir_list&amp;t=resource\/res_list&amp;verify=1&amp;id=open1419316505&amp;token=&amp;lang=zh_CN\" name=\"\u7f51\u7ad9\u5e94\u7528\u5fae\u4fe1\u767b\u5f55\u5f00\u53d1\u6307\u5357\" target=\"_blank\" title=\"\u7f51\u7ad9\u5e94\u7528\u5fae\u4fe1\u767b\u5f55\u5f00\u53d1\u6307\u5357\">\u7f51\u7ad9\u5e94\u7528\u5fae\u4fe1\u767b\u5f55\u5f00\u53d1\u6307\u5357<\/a>\n\t<\/li>\n<\/ul>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3682\">WebFlux \u7f51\u7ad9\u5fae\u4fe1\u7b2c\u4e09\u65b9\u767b\u5f55<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u5fae\u4fe1\u7684\u5f3a\u793e\u4ea4\u5c5e\u6027\u8ba9\u5176\u62e5\u6709\u4f17\u591a\u7684\u7528\u6237\u3002\u4e00\u4e9b\u7b2c\u4e09\u65b9\u7f51\u7ad9\uff0c\u5982\u679c\uff0c\u6bcf\u4e2a\u90fd\u505a\u4e00\u5957\u7528\u6237\u7ba1\u7406\u7cfb\u7edf\uff0c\u8ba9\u6bcf\u4e2a\u7528\u6237\u90fd\u518d\u6ce8\u518c\u4e00\u904d\uff0c\u9996 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1701,73,558,446,445],"class_list":["post-3682","post","type-post","status-publish","format-standard","hentry","category-java","tag-webflux","tag-73","tag-558","tag-js-sdk","tag-445"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3682"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3682\/revisions"}],"predecessor-version":[{"id":3683,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3682\/revisions\/3683"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}