{"id":10007019,"date":"2022-12-27T15:42:00","date_gmt":"2022-12-27T07:42:00","guid":{"rendered":"https:\/\/ityet.com\/?p=10007019"},"modified":"2022-12-27T15:42:00","modified_gmt":"2022-12-27T07:42:00","slug":"web%e5%ba%94%e7%94%a8%e6%80%8e%e6%a0%b7%e8%8e%b7%e5%8f%96access-token%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10007019","title":{"rendered":"Web\u5e94\u7528\u600e\u6837\u83b7\u53d6Access Token\uff1f"},"content":{"rendered":"<h3>1.\u5728\u8054\u76df\u521b\u5efa\u670d\u52a1\u5668\u5e94\u7528<\/h3>\n<p>\u53c2\u8003\u6587\u6863\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=Vcy55kYNHBfkZXFn7sDeSw%3D%3D.RDLnQ2yGKkaEdp3dqkrK1iirnbJIXZRsrDG%2BLAYcChUN7rULPehAsqt%2BfTne9t%2BWrhXfTh4yuLV1Gz%2B%2BJUr9MGRwZJPumoRz1612Qa1yAlUafiGzyqzZd7Kgts3BBMguIo8L7qso232SLfmuTj5J2OqaTn3TP4bGbJvG%2F%2F5yZN0%3D\" rel=\"nofollow\">\u5f00\u53d1\u51c6\u5907<\/a><\/p>\n<h3>2.\u83b7\u53d6\u7528\u6237\u7ea7Access Token<\/h3>\n<p>2.1    \u83b7\u53d6code<\/p>\n<p>\u53c2\u8003\u6587\u6863\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=VM88YA0Ak7OfXtmdut67rw%3D%3D.4ODCha4sH%2FRsL3ivu194mTmnHkht8Oftz2SfVEFlNcjjhs1tngpZDfuQDGjSZK6YCWFtAwSYUdIWbrNO70Mtp1D9TCVj53mIlB%2BWVglS2y9TF6mRRGYBOANholCbAJuT43NOSHVnc1MExFjWXFjyLvlFKa%2BR%2BIHWYdv1m6K0CvBjn5B5Lx3BQ61jnj7annSo9jBnKlcosTbbLVY6IkxNaQ%3D%3D\" rel=\"nofollow\">\u63a5\u5165\u534e\u4e3a\u5e10\u53f7\u83b7\u53d6\u51ed\u8bc1<\/a><\/p>\n<p>2.1.1    \u5148\u6309\u7167\u8df3\u8f6c\u94fe\u63a5\u8fdb\u884c\u914d\u7f6eurl<\/p>\n<pre><code>https:\/\/oauth-login.cloud.huawei.com\/oauth2\/v3\/authorize?\nresponse_type=code&amp;\naccess_type=offline&amp;\nstate=state_parameter_passthrough_value&amp;\nclient_id=APP ID&amp;\nredirect_uri=\u5e94\u7528\u7684\u56de\u8c03\u5730\u5740&amp;\nscope=openid+profile<\/code><\/pre>\n<p>\u63a5\u53e3\u7684\u63cf\u8ff0\u548c\u53c2\u6570\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hVW\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u793a\u4f8b\uff1a\u521b\u5efa\u6d4b\u8bd5\u7684App<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hVX\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4f20\u5165url: <a href=\"https:\/\/link.segmentfault.com\/?enc=USbqBV0hjyKAG06C4jQ6oA%3D%3D.7wi2l3dnnJnlznE4%2FTycND8zS6OAWMXIX3TXcNH2yGL403%2BN%2BkOBpMrmBWtAjztucO0phB60DMybJMcMJfDv4i%2FXYi2wizn8xEdRMWRgPoLcPZefwOgkjn4T81Cmlt2G5%2BTg8WQOTa1UL8veZsKaPtjdQZLXAzpB2JKJnoFmfY4gcQH7qwJRSTKQp9Ur1H2qJqPXXBRUlj8LvQViN01DFo%2Fm9yQUCW8FgujJvjmtgXuWUsmb8NF50koy8KchPzgb\" rel=\"nofollow\">https:\/\/oauth-login.cloud.hua&#8230;<\/a><\/p>\n<p>2.1.2    \u7528\u6237\u767b\u5f55\u5e76\u6388\u6743<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hVY\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5f53\u8bf7\u6c42\u8df3\u8f6c\u5230OAuth\u670d\u52a1\uff0cOAuth\u670d\u52a1\u4f1a\u5f15\u5bfc\u7528\u6237\u8fdb\u884c\u6388\u6743\uff0c\u5f39\u51fa\u6388\u6743\u9875\u9762\u7ed9\u7528\u6237\uff0c\u663e\u793a\u5e94\u7528\u7684\u540d\u79f0\u548c\u56fe\u6807\u4ee5\u53ca\u8be5\u5e94\u7528\u6240\u7533\u8bf7\u6388\u6743\u7684scope\u6743\u9650\u5217\u8868\uff0c\u8f93\u5165\u534e\u4e3a\u5e10\u53f7\u53ca\u5bc6\u7801\u5b8c\u6210\u767b\u5f55\u6388\u6743\u3002<\/p>\n<p>2.1.3    OAuth\u670d\u52a1\u5c06\u54cd\u5e94\u503c\u901a\u8fc7\u56de\u8c03\u5730\u5740redirect_uri\u56de\u8c03\u7ed9\u5e94\u7528\u3002<\/p>\n<p>\u5982\u679c\u7528\u6237\u540c\u610f\u6388\u6743\uff0c\u5219\u56de\u8c03\u8bf7\u6c42\u4e2d\u5e26\u6709\u6388\u6743\u7801code\u3002<\/p>\n<pre><code>https:\/\/www.thirdwebdemo.com\/redirect_url?\ncode=&lt;\u8fd4\u56de\u7684\u6388\u6743\u7801code&gt;<\/code><\/pre>\n<p>\u5982\u679c\u7528\u6237\u4e0d\u540c\u610f\u6388\u6743\uff0c\u5219\u56de\u8c03\u8bf7\u6c42\u4e2d\u5305\u542b\u9519\u8bef\u6d88\u606f\u3002<\/p>\n<pre><code>https:\/\/www.thirdwebdemo.com\/redirect_url #error=1107&amp;error_description=access+denied<\/code><\/pre>\n<p>2.2    \u901a\u8fc7code\u83b7\u53d6Access Token <\/p>\n<p>\u53c2\u8003\u6587\u6863\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=55qWTN%2FVpeEmXp56fw7zWA%3D%3D.aam4txOVWtw5vJryp9HoCbV0xh8TIP6TlMfuMJ1VZNPclHex1bM8NMO%2Bq5LRioXG6wiaJPDDVBQ35PGE%2F4d0RGAEMCgpJF6x3R8Gkf4MBbRnp1BZRPRlI1WdAoiMMCXds4n%2FxWgbFMHVKwTVg%2BgjculaS6Am3MuCL2BluBpNL316kXzfml92IGiEur%2FLsVkF\" rel=\"nofollow\">\u83b7\u53d6\u51ed\u8bc1Access Token<\/a><\/p>\n<p>Authorization Code\u53ea\u67095\u5206\u949f\u6709\u6548\u671f\uff0c\u5e76\u4e14\u7528\u5b8c\u4e00\u6b21\u5c31\u4f1a\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u7531\u7528\u6237\u6388\u6743\uff0c\u751f\u6210Authorization Code\u3002<\/p>\n<p>2.2.1    \u63a5\u53e3\u8bf4\u660e<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hVZ\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hV0\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>2.2.2    \u76f4\u63a5\u901a\u8fc7code\u83b7\u53d6access_token\u3001refresh_token<\/p>\n<p>\u5907\u6ce8\uff1a\u901a\u8fc72.1.3\u83b7\u53d6\u7684code\u9700\u8981UrlDecode\u540e\u518d\u4f7f\u7528<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hV1\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>Postman\u8bf7\u6c42\u793a\u4f8b\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hV2\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8bf7\u6c42\u793a\u4f8b\uff1a<\/p>\n<pre><code>POST \/oauth2\/v3\/token HTTP\/1.1\nHost: oauth-login.cloud.huawei.com\nCache-Control: no-cache\nPostman-Token: 923683a5-7379-03f5-b83f-072ba217fc65\nContent-Type: application\/x-www-form-urlencoded\n\ngrant_type=authorization_code&amp;code=DwEEABlWuXdOMrHWphJ7ixKxqkMiTfdoFX11KIcY0CP8gL2Qq5b5MNZpGtPWHKK5KBHm6u6KDP1BXq8JRunU4xIz4DV2zbdGCzEPCbuRaDz%2FzgbzWV6ty2K1TcbToSEdDszr1to17JbGiI5yM7oUx5kEf200rCvVBEGWy8a%2BBCADZ8%2BWPAAEd2O%2BUnjqoAhDSjs2s3ate0heX3DFAUrtwIOcZLCK%2FWby%2BU2oD2eaXX0CXhBNY5PE0nzBLxr4%2B5%2BYH%2BFh8%2BSssOl3repWjH0bxni8iQ%3D%3D&amp;client_id=107408391&amp;client_secret=caa9b93ef209bcb8f754a5742b7d617d5db2bd5901ae8656b60e79cca93825f8&amp;redirect_uri=https%3A%2F%2Fwww.thirdwebdemo.com%2Fredirect_url<\/code><\/pre>\n<p>2.2.3    \u901a\u8fc7refresh_token\u83b7\u53d6access_token<\/p>\n<p>code\u7684\u6709\u6548\u671f\u53ea\u67095\u5206\u949f\uff0crefresh_token\u7684\u6709\u6548\u671f\u534a\u5e74\uff0caccess_token\u7684\u6709\u6548\u671f1\u4e2a\u5c0f\u65f6\u3002\u4e0d\u5efa\u8bae\u6bcf\u6b21\u90fd\u83b7\u53d6code\u6765\u6362\u53d6access_token\uff0c\u53ef\u4ee5\u76f4\u63a5\u4fdd\u5b58refresh_token\uff0c\u518d\u4f7f\u7528refresh_token\u6362access_token\u7684\u65b9\u5f0f\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hV3\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8bf7\u6c42\u793a\u4f8b\uff1a<\/p>\n<pre><code>POST \/oauth2\/v3\/token HTTP\/1.1\nHost: oauth-login.cloud.huawei.com\nCache-Control: no-cache\nPostman-Token: 53d26c97-c7d8-3d49-042a-db7a4b2768a5\nContent-Type: application\/x-www-form-urlencoded\n\ngrant_type=refresh_token&amp;client_id=107408391&amp;client_secret=caa9b93ef209bcb8f754a5742b7d617d5db2bd5901ae8656b60e79cca93825f8&amp;refresh_token=DAECANR5QD9Ta3YKIn2Pwpmq8g6CyOGcsz3iNsxq8YXBpZs6EGlqb%2FM8Iyc%2FXVORdoqb%2FaZXKs9jqz72kQCmp9Om%2B7%2Fp7ff6QfH%2FKN32GwsE9xq%2BTbDT<\/code><\/pre>\n<p>3    \u83b7\u53d6\u5e94\u7528\u7ea7Access Token <\/p>\n<p>\u53c2\u8003\u6587\u6863\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=mBVeFnXO%2Bcz7Zz0yRSGb2w%3D%3D.1Y%2Be8Wuaogy2AxW%2B3cRHTwZOZED3c7Memna7aF9jZC%2BoBo0EoX%2F4HsKbJf%2FkJToymBv67rnhO6e0aRiUFnYh6R22np13SUl90SbifvvILWWxmoUEKiFtcLOp%2FehctXXzxiwVMRcYqj3%2Bh%2FltZvvLIxgkgoCTFy%2FybW6PXZBBQOLkjio0TlsgtKv54ifV24kdXLiAs8Mpv05fceqbSsXnjQ%3D%3D\" rel=\"nofollow\">\u5ba2\u6237\u7aef\u6a21\u5f0f\uff08Client Credentials\uff09<\/a><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc5hV4\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8bf7\u6c42\u793a\u4f8b\uff1a<\/p>\n<pre><code>POST \/oauth2\/v3\/token HTTP\/1.1\nHost: oauth-login.cloud.huawei.com\nCache-Control: no-cache\nPostman-Token: 1e120cb0-fa6f-e622-1bf0-66a13c82b643\nContent-Type: application\/x-www-form-urlencoded\n\ngrant_type=client_credentials&amp;client_id=107408391&amp;client_secret=caa9b93ef209bcb8f754a5742b7d617d5db2bd5901ae8656b60e79cca93825f8<\/code><\/pre>\n<p><strong>\u4e86\u89e3\u66f4\u591a\u8be6\u60c5&gt;&gt;<\/strong><\/p>\n<p>\u8bbf\u95ee<a href=\"https:\/\/link.segmentfault.com\/?enc=JzGSVBTqFCWk%2BOlripxtHA%3D%3D.ASNwALLTLpwQD041jp76t1gwdXR2PKs7yOjLkSdhp6OnDCfFmakrHNnSZ0%2FQitUy2cuwqJk3hVqxFXNxeX63gQ%3D%3D\" rel=\"nofollow\">\u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df\u5b98\u7f51<\/a>  <br \/>\u83b7\u53d6<a href=\"https:\/\/link.segmentfault.com\/?enc=FY7w2vI9vlUo%2Blo4WsIzMA%3D%3D.xwgfQFhJG0EvMNpuToAkbm1moCd76ee8e9LDflkhuO0E4D1Bm9DRNYpNaHphV5kbxv7vkrnTyv%2FXzcKeUGTJG89amzj1mOWLPuFKlOpfcUc%3D\" rel=\"nofollow\">\u5f00\u53d1\u6307\u5bfc\u6587\u6863<\/a>  <br \/>\u534e\u4e3a\u79fb\u52a8\u670d\u52a1\u5f00\u6e90\u4ed3\u5e93\u5730\u5740\uff1a<a href=\"https:\/\/link.segmentfault.com\/?enc=L4FeZ2nVZPSd6KuZubuE1Q%3D%3D.53mkjhbd%2F7kyYLg0scFKBSnyqAtm6okGBT33SDYouvw%3D\" rel=\"nofollow\">GitHub<\/a>\u3001<a href=\"https:\/\/link.segmentfault.com\/?enc=nLUjBL3eTEYVVStjxGW%2FaQ%3D%3D.PEZJu%2FUMF8rSjrrXxz3Xxdw2CFW32e4%2F3C0WTydhV%2BQ%3D\" rel=\"nofollow\">Gitee<\/a><\/p>\n<p><strong>\u5173\u6ce8\u6211\u4eec\uff0c\u7b2c\u4e00\u65f6\u95f4\u4e86\u89e3 HMS Core \u6700\u65b0\u6280\u672f\u8d44\u8baf~<\/strong><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000043167247\">https:\/\/segmentfault.com\/a\/1190000043167247<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5728\u8054\u76df\u521b\u5efa\u670d\u52a1\u5668\u5e94\u7528 \u53c2\u8003\u6587\u6863\uff1a\u5f00\u53d1\u51c6\u5907 2.\u83b7\u53d6\u7528\u6237\u7ea7Access Token 2.1 \u83b7\u53d6code \u53c2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10007019","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10007019"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007019\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10007019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10007019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10007019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}