{"id":266,"date":"2022-03-23T18:16:24","date_gmt":"2022-03-23T10:16:24","guid":{"rendered":"https:\/\/sit-open-doc.jkos.app\/?post_type=docs&#038;p=266"},"modified":"2022-06-28T15:06:38","modified_gmt":"2022-06-28T07:06:38","slug":"%e5%9f%ba%e7%a4%8e%e9%96%8b%e6%94%be%e8%83%bd%e5%8a%9b-%e6%8e%88%e6%ac%8a","status":"publish","type":"docs","link":"https:\/\/open-doc.jkos.com\/?docs=inapp-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%9c%8d%e5%8b%99\/web-sdk\/v2-0-3\/%e5%9f%ba%e7%a4%8e%e9%96%8b%e6%94%be%e8%83%bd%e5%8a%9b-%e6%8e%88%e6%ac%8a","title":{"rendered":"\u57fa\u790e\u958b\u653e\u80fd\u529b &#8211; \u6388\u6b0a"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">getAuthCode<\/h2>\n\n\n\n<p>\u901a\u904e\u547c\u53eb&nbsp;<strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">jkos.getAuthCode<\/mark><\/strong>&nbsp;\u5728\u9700\u8981\u53d6\u5f97\u4f7f\u7528\u8005\u7684\u6388\u6b0a\u8cc7\u6599\u6642\uff0c\u559a\u8d77\u8857\u53e3\u539f\u751f\u7684\u6388\u6b0a\u9801\u9762\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u4f7f\u7528\u65b9\u6cd5\">\u4f7f\u7528\u65b9\u6cd5<a href=\"https:\/\/open.jkos.com\/docs\/next\/sdk-base\/authentication\/getAuthCode#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95\">\u200b<\/a><\/h3>\n\n\n\n<pre title=\"\u51fd\u5f0f\" class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript line-numbers\">jkos.getAuthCode(data, callback);<\/code><\/pre>\n\n\n\n<pre title=\"\u7bc4\u4f8b\" class=\"wp-block-code\"><code lang=\"javascript\" class=\"language-javascript line-numbers\">&lt;button id=\"test\">getAuthCode&lt;\/button> \n\n&lt;script> \ndocument.querySelector('#test').addEventListener('click', () => {\n  jkos.getAuthCode ({\n    clientId :  'string' ,\n    scopes : ['userInfo'],\n    onSuccess: (authCode) => {},\n    onError: (e) => {\n      console.log(e.error)\n      console.log(e.errorMessage)\n    },\n    onRejectAuth: () => {}\n  }, (res) => {\n    console.log(res.error)\n    console.log(res.errorMessage)\n  })\n});\n&lt;\/script><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u5165\u53c3\u8aaa\u660e\">\u5165\u53c3\u8aaa\u660e<a href=\"https:\/\/open.jkos.com\/docs\/next\/sdk-base\/authentication\/getAuthCode#%E5%85%A5%E5%8F%83%E8%AA%AA%E6%98%8E\">\u200b<\/a><\/h3>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">\u5fc5\u9808<\/mark><\/strong>&nbsp;\u7b2c\u4e00\u500b\u53c3\u6578\uff1adata<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>\u53c3\u6578<\/th><th>\u5fc5\u586b<\/th><th>\u578b\u614b<\/th><th>\u8aaa\u660e<\/th><\/tr><\/thead><tbody><tr><td>clientId<\/td><td>\u662f<\/td><td><code>string<\/code><\/td><td>Client ID<\/td><\/tr><tr><td>scopes<\/td><td>\u662f<\/td><td><code>string<\/code><\/td><td>\u9700\u8981\u63d0\u4f9b\u7684\u6b0a\u9650\u5c6c\u6027\uff0c\u53ef\u4f7f\u7528 Array \u6307\u5b9a<strong>\u591a\u500b scope<\/strong><\/td><\/tr><tr><td>onSuccess<\/td><td>\u662f<\/td><td><code>function<\/code><\/td><td>\u53d6\u5f97&nbsp;<strong>authCode<\/strong>&nbsp;\u6210\u529f\u7684\u56de\u547c\u51fd\u5f0f<\/td><\/tr><tr><td>onError<\/td><td>\u5426<\/td><td><code>function<\/code><\/td><td>\u53d6\u5f97&nbsp;<strong>authCode<\/strong>&nbsp;\u5931\u6557\u7684\u56de\u547c\u51fd\u5f0f<\/td><\/tr><tr><td>onRejectAuth<\/td><td>\u5426<\/td><td><code>function<\/code><\/td><td>\u7576\u4f7f\u7528\u8005\u62d2\u7d55\u6388\u6b0a\u6642\uff0c\u9ede\u64ca&nbsp;<strong>&lt; (\u8fd4\u56de)<\/strong>\u6216&nbsp;<strong>X (\u95dc\u9589)<\/strong>\uff0c\u6703\u547c\u53eb\u7684\u51fd\u5f0f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">\u975e\u5fc5\u9808<\/mark><\/strong>&nbsp;\u7b2c\u4e8c\u500b\u53c3\u6578\uff1a callback<\/p>\n\n\n\n<p>\u8fd4\u56de\u8a2d\u5b9a\u51fd\u5f0f\u6210\u529f\u8207\u5426\uff0c\u4e5f\u53ef\u4f7f\u7528&nbsp;<code>async\/await<\/code>&nbsp;\u53d6\u4ee3 callback<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>\u53c3\u6578<\/th><th>\u578b\u614b<\/th><th>\u8aaa\u660e<\/th><\/tr><\/thead><tbody><tr><td>error<\/td><td><code>number<\/code><\/td><td>\u932f\u8aa4\u78bc &#8211;\u00a0<a href=\"https:\/\/open-doc.jkos.com\/?docs=sdk\/v2-0-6\/%e9%8c%af%e8%aa%a4%e4%bb%a3%e7%a2%bc\" data-type=\"URL\" data-id=\"https:\/\/open-doc.jkos.com\/?docs=sdk\/v2-0-6\/%e9%8c%af%e8%aa%a4%e4%bb%a3%e7%a2%bc\" target=\"_blank\" rel=\"noreferrer noopener\">\u8a73\u60c5\u8acb\u53c3\u898b\u932f\u8aa4\u78bc\u8aaa\u660e<\/a><\/td><\/tr><tr><td>errorMessage<\/td><td><code>string<\/code><\/td><td>\u6b64\u63cf\u8ff0\u70ba\u76f8\u95dc\u932f\u8aa4\u7684 ASCII \u7de8\u78bc\u53ef\u8b80\u6587\u5b57<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u932f\u8aa4\u78bc\u56de\u8986\">\u932f\u8aa4\u78bc\u56de\u8986<a href=\"https:\/\/open.jkos.com\/docs\/v2.0.3\/sdk-base\/authentication\/getAuthCode#%E9%8C%AF%E8%AA%A4%E7%A2%BC%E5%9B%9E%E8%A6%86\">\u200b<\/a><\/h3>\n\n\n\n<figure class=\"wp-block-table is-style-stripes has-extra-small-font-size\"><table><thead><tr><th>\u4ee3\u78bc<\/th><th>\u8aaa\u660e<\/th><\/tr><\/thead><tbody><tr><td>15<\/td><td>\u7cfb\u7d71\u4e0d\u652f\u63f4<\/td><\/tr><tr><td>16<\/td><td>\u683c\u5f0f\u932f\u8aa4<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"featured_media":0,"parent":261,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-266","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266"}],"version-history":[{"count":2,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/266\/revisions"}],"predecessor-version":[{"id":723,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/266\/revisions\/723"}],"up":[{"embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/261"}],"next":[{"title":"\u57fa\u790e\u958b\u653e\u80fd\u529b - \u5c0e\u822a\u6b04","link":"https:\/\/open-doc.jkos.com\/?docs=inapp-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%9c%8d%e5%8b%99\/web-sdk\/v2-0-3\/%e5%9f%ba%e7%a4%8e%e9%96%8b%e6%94%be%e8%83%bd%e5%8a%9b-%e5%b0%8e%e8%88%aa%e6%ac%84","href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/265"}],"wp:attachment":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}