{"id":235,"date":"2022-03-23T03:39:42","date_gmt":"2022-03-22T19:39:42","guid":{"rendered":"https:\/\/sit-open-doc.jkos.app\/?post_type=docs&#038;p=235"},"modified":"2025-05-26T16:56:21","modified_gmt":"2025-05-26T08:56:21","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-6\/%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 has-css-opacity is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"way\">\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\"&gt;getAuthCode&lt;\/button&gt; \n\n&lt;script&gt; \ndocument.querySelector('#test').addEventListener('click', () =&gt; {\n  jkos.getAuthCode({\n      clientId :  'string' ,\n      scopes : ['phone', 'email', 'barcode'],\n      onSuccess: (authCode) =&gt; {},\n      onError: (e) =&gt; {\n        console.log(e.error)\n        console.log(e.errorMessage)\n      },\n      onRejectAuth: () =&gt; {}\n    }, (res) =&gt; {\n      console.log(res.error)\n      console.log(res.errorMessage)\n  })\n})\n&lt;\/script&gt;<\/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>userId<\/td><td>\u5426<\/td><td><code>string<\/code><\/td><td>\u81ea\u6709\u5e73\u53f0\u6703\u54e1\u7684\u4f7f\u7528\u8005 ID\uff08\u82e5 scopes \u6b04\u4f4d\u6709\u586b\u5beb&nbsp;<strong>&#8220;binding&#8221;<\/strong>&nbsp;\u6642\u9700\u5fc5\u586b\uff09<\/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><a href=\"https:\/\/open-doc.jkos.com\/?docs=inapp-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%9c%8d%e5%8b%99\/oauth\/%e9%96%8b%e6%94%be%e5%b9%b3%e5%8f%b0%e7%b0%a1%e4%bb%8b#3-scope\" data-type=\"link\" data-id=\"https:\/\/open-doc.jkos.com\/?docs=inapp-%e7%ac%ac%e4%b8%89%e6%96%b9%e6%9c%8d%e5%8b%99\/oauth\/%e9%96%8b%e6%94%be%e5%b9%b3%e5%8f%b0%e7%b0%a1%e4%bb%8b#3-scope\">\u591a\u500b scope<\/a><\/strong>\uff0c\u50cf\u662f\u00a0<code>['phone','email','barcode']<\/code><\/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<div class=\"admonition admonition-info alert alert--info\">\n <div class=\"admonition-heading\">\n  <h5><span class=\"admonition-icon\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"14\" height=\"16\" viewBox=\"0 0 14 16\"><path fill-rule=\"evenodd\" d=\"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z\"><\/path><\/svg><\/span> \u5982\u4f55\u4f7f\u7528\u81ea\u6709\u5e73\u53f0\u6703\u54e1 ID \u7d81\u5b9a\u8857\u53e3\u5e33\u865f\uff1f\n  <\/h5>\n <\/div>\n<div class=\"admonition-content\">\n <p>\u555f\u7528\u65b9\u5f0f\u70ba\uff1a<\/p>\n <ul>\n   <li>\u958b\u901a binding scopes (\u9700\u8207\u8857\u53e3\u7a97\u53e3\u7533\u8acb)<\/li>\n   <li>\u547c\u53eb <strong>getAuthCode()<\/strong> \u6642\n     <ul>\n       <li>scopes \u586b\u5165 <code>binding<\/code><\/li>\n       <li>userId \u586b\u5165 <code>\u81ea\u6709\u5e73\u53f0\u6703\u54e1 ID<\/code><\/li>\n     <\/ul>\n   <\/li>\n  <\/ul>\n <\/div>\n<\/div>\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;&nbsp;\u8a73\u60c5\u8acb\u53c3\u898b\u932f\u8aa4\u4ee3\u78bc\u9644\u9304<\/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\/next\/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<p>\u8acb\u53c3\u95b1 <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\">\u932f\u8aa4\u4ee3\u78bc\u9644\u9304<\/a>\u3002<\/p>\n","protected":false},"featured_media":0,"parent":230,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-235","docs","type-docs","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/235","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=235"}],"version-history":[{"count":10,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/235\/revisions"}],"predecessor-version":[{"id":1479,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/235\/revisions\/1479"}],"up":[{"embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=\/wp\/v2\/docs\/230"}],"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-6\/%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\/234"}],"wp:attachment":[{"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/open-doc.jkos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}