1. 程式人生 > 其它 >釘釘掃碼登入第三方網站

釘釘掃碼登入第三方網站

掃碼登入第三方網站 掃碼登入第三方網站
      <main id="topic-2040858">
        <p data-tag="shortdesc" id="shortdesc-mip-fut-h2q" class="shortdesc"><span style="color: rgba(17,31,44,0.40);font-size:14px;">更新時間:2022-02-24</span><br></p><div data-tag="taskbody" id="taskbody-3du-a6n-ny3" class="taskbody"><section id="section-qv2-w4z-gc9" class="section"><h2 data-tag="title" id="title-lm1-m6k-vku" class="title">簡介</h2><p id="p-fxt-bhc-9v5">本教程指導你如何實現使用者通過釘釘掃碼直接登入到第三方網站。在本場景中,第三方網站可以獲取在正在訪問使用者的釘釘身份無需使用者輸入賬號密碼。</p><h3 id="p-9st-nv4-3y3">準備工作</h3><p id="p-2t7-0ao-jt2">在開始本教程前,確保你已經完成了以下準備工作:</p><ul id="ul-we3-568-pog"><li id="li-ndq-zlq-xid"><p id="p-dho-7fe-ihd">已經完成了釘釘開發者的註冊與啟用並擁有了子管理員和開發者許可權。若尚未完成,請參考<a href="/document/app/become-a-dingtalk-developer#topic-2024337" id="a-yuj-492-q1p" data-tag="xref" baseurl="t2039522_v1_0_0.xdita" data-node="2728530" data-root="66689" class="xref" target="_blank">成為釘釘開發者</a>。</p></li><li id="li-jve-16z-hff"><p id="p-74e-wmm-dbk">已經安裝了Java開發環境。若未安裝,請訪問<a href="https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html" id="a-u7p-9ms-yt1" data-tag="xref" baseurl="" class="xref" target="_blank">Oracle官網</a>下載。</p></li><li id="li-a1u-ofe-0mh"><p id="p-z24-2uh-e51">已經安裝了Java專案構建工具Maven。若未安裝,請訪問<a href="http://maven.apache.org/index.html" id="a-cqx-m63-utr" data-tag="xref" baseurl="" class="xref" target="_blank">Apache Maven</a>下載。</p></li><li id="li-3xp-j2a-mrf"><p id="p-jt1-daq-u9e">已下載並安裝了<b>IntelliJ IDEA</b>開發工具。若未安裝,請訪問<a href="https://www.jetbrains.com/idea/download/#section=windows" id="a-ufo-nne-ahx" data-tag="xref" baseurl="t2039522_v1_0_0.xdita" class="xref" target="_blank">IntelliJ IDEA</a>。</p></li></ul></section><section id="section-urz-xm3-js8" class="section"><h2 data-tag="title" id="title-kqv-ew9-w7o" class="title">建立應用</h2><p id="p-eof-kor-559">在本部分,你將在開發者後臺建立一個H5微應用,並完成通訊錄許可權的配置,用於本企業使用者登入。</p><ol id="ol-upa-2gb-npf"><li id="li-onj-z9z-5kj"><p id="p-vbt-1wc-1fw">登入<a href="https://open-dev.dingtalk.com/" id="a-m4o-2n8-7pa" data-tag="xref" baseurl="" class="xref" target="_blank">釘釘開發者後臺</a>。</p><div type="note" id="note-wvr-wmr-nm6" class="note note-note"><div class="note-icon-wrapper"><i class="icon-note note note"></i></div><div class="noteContentSpan"><strong>說明 </strong><p id="p-h24-z5c-yid">只有管理員和子管理員可登入開發者後臺。</p></div></div></li><li id="li-t8s-zkg-xon"><p id="p-n4l-1vw-o22">在<b>開發者後臺</b>頁面,選擇<b>企業</b><b>內部開發</b>,然後單擊<b>建立應用</b>。</p><p id="p-6zz-e3q-ljn"><img alt="p255125 " src="https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/2260270261/p260944.png" placement="break" id="img-ucw-ckl-cd9" class="image break"><img alt="" placement="break" id="img-25g-s26-rsj" class="image break"></p></li><li id="li-p5s-byl-y40"><p id="p-dxp-ncd-omj">在彈出的建立應用頁面中填寫基本資訊,然後單擊<b>確定建立</b>。</p><ul id="ul-dhi-iru-vzm"><li id="li-oqz-j4a-n5z"><p id="p-ett-9jo-mbt"><b>應用型別</b>:選擇<b>H5微應用</b>。</p></li><li id="li-zjz-zfq-ziy"><p id="p-3uw-90i-x67"><b>開發方式</b>:選擇<b>企業自助開發</b>。</p></li></ul><img alt="p238094 " src="https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/4419648161/p261026.png" placement="break" id="img-bst-oee-tja" class="image break"></li><li id="li-fo0-pg0-c6x"><p id="p-uvm-9zo-82h">應用建立完成後,在<b>基礎資訊</b>頁面,複製應用的<b>AppKey</b>和<b>AppSecret</b>備用。</p><img alt="p238073 " src="https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/4419648161/p261028.png" placement="break" id="img-jaj-qjx-246" class="image break"></li><li id="li-mx7-xaz-4xw"><p id="p-lzu-acy-vp7">單擊<b>開發管理</b>進入開發管理頁面,然後單擊<b>修改,</b>並根據以下內容配置開發資訊。</p><ul id="ul-s1y-xao-9lh"><li id="li-s54-nll-itj"><p id="p-akm-rzi-1x8"><b>開發模式</b>:選擇<b>開發應用</b>。</p></li><li id="li-ll3-kb7-usr"><p id="p-g4f-4k9-5u0"><b>伺服器出口IP</b>:輸入呼叫釘釘服務端API時使用的IP即企業伺服器的公網IP,多個IP請以英文逗號","隔開,支援帶一個*號萬用字元的IP格式。</p><p id="p-tv4-fx6-6gc">本教程設定為<code data-tag="code" class="code">127.0.0.1</code>。</p></li><li id="li-pbz-xco-waj"><p id="p-xia-gil-41i"><b>應用首頁地址</b>:輸入應用首頁URL,在移動端工作臺點選應用圖示會跳轉到此頁面。可輸入後端服務部署的伺服器的IP或域名。例如:<code data-tag="code" class="code">http://公網IP:8080</code>。</p><p id="p-eod-kx8-31y">本教程設定為<code data-tag="code" class="code">https://ding-doc.dingtalk.com/</code>。</p><img alt="p235737" src="https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/4389648161/p261065.png" placement="break" id="img-qty-8l8-vj7" class="image break"></li></ul></li><li id="li-u8c-qwh-7x4"><p id="p-60w-uy8-gud">單擊<b>許可權管理</b>進入許可權管理頁面,然後根據以下配置新增介面呼叫許可權。</p><ol id="ol-s1q-grt-s0d"><li id="li-a5x-x9j-nmz"><p id="p-1nk-lyv-2v7">許可權範圍選擇<b>全部員工</b>,然後選擇<b>通訊錄管理</b>。</p></li><li id="li-c43-ev4-qjl"><p id="p-hv3-km0-lzf">選擇<b>通訊錄部門資訊讀許可權</b>和<b>通訊錄部門成員讀許可權</b>,然後單擊<b>申請許可權</b>。</p><img alt="p237933 " src="https://help-static-aliyun-doc.aliyuncs.com/assets/img/zh-CN/2494887161/p260978.png" placement="break" id="img-8ux-1bz-24s" class="image break"></li></ol></li></ol></section><section id="section-w09-v3s-jex" class="section"><h2 data-tag="title" id="title-v7t-zqu-9uk" class="title">配置內網穿透</h2><p id="p-jqn-tq4-sq2">在本部分,你將使用釘釘內網穿透工具生成一個公網域名用於教程測試。</p><ol id="ol-0tp-hta-8ki"><li id="li-b41-ouk-ib5"><p id="p-jby-kwr-fbc">開啟命令列工具,執行以下命令,下載內網穿透工具。</p><pre id="codeblock-rc4-524-nib" data-tag="codeblock" class="pre codeblock"><code class="hljs awk">git clone https:<span class="hljs-regexp">//gi</span>thub.com<span class="hljs-regexp">/open-dingtalk/</span>pierced.git</code><div class="code-copy" data-clipboard-text="git clone https://github.com/open-dingtalk/pierced.git"><span><svg t="1642752622185" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9733" width="18" height="18"><path d="M127.962074 767.742104C57.571556 767.742104 0 710.155378 0 639.78003V127.962074C0 57.579141 57.579141 0 127.962074 0h447.844504C646.181926 0 697.35917 51.18483 703.753481 121.560178v6.394311c0 25.592415-19.190519 51.18483-51.184829 51.18483-31.986726 0-44.782933-25.592415-44.782933-51.18483 0-12.796207-12.796207-25.592415-25.592415-31.986726H127.962074c-12.796207 0-25.592415 12.796207-31.986726 25.592415v518.219852c0 12.796207 12.796207 25.592415 25.592415 31.986726h70.375348c25.592415 0 51.18483 19.190519 51.18483 51.184829s-25.592415 44.790519-51.18483 44.790519h-63.981037zM895.689007 351.876741H447.844504c-12.796207 0-25.58483 12.796207-31.986726 25.592415v518.219851c0 12.803793 12.796207 25.6 25.592415 31.994312h454.2464c12.796207 0 25.592415-12.796207 31.986726-25.592415v-518.219852c0-12.796207-12.796207-25.592415-31.986726-31.994311z m0-95.967763c70.375348 0 127.954489 57.579141 127.954489 127.962074v511.825541c0 70.375348-57.579141 127.954489-127.962074 127.954488H447.852089c-70.375348 0-127.954489-57.579141-127.954489-127.962074V383.878637c0-70.382933 57.579141-127.962074 127.962074-127.962074h447.844504z" p-id="9734"></path></svg></span><div class="code-copy-tip">一鍵複製</div></div></pre></li><li id="li-uyv-0fk-hk9"><p id="p-w2r-a2l-hj2">執行以下命令,啟動內網穿透。</p><ul id="ul-qps-bi1-kyl"><li id="li-w75-3pg-f5p"><p id="p-i38-bjy-sif">Windows執行以下命令:</p><div type="note" id="note-050-c9r-6vl" class="note note-note"><div class="note-icon-wrapper"><i class="icon-note note note"></i></div><div class="noteContentSpan"><strong>說明 </strong><p id="p-aj8-2ic-rhv">Windows需使用cmd工具開啟命令列。</p></div></div><pre id="codeblock-njh-7t6-5y6" data-tag="codeblock" class="pre codeblock"><code class="hljs mipsasm">cd windows_64

ding -config=ding.cfg -subdomain=abcde 8080

一鍵複製
  • MAC執行以下命令:

    cd mac_64
    chmod 777 ./ding
    ./ding -config=./ding.cfg -subdomain=abcde 8080
    一鍵複製
  • 注意

    啟動內網穿透時,請不要直接使用abcde字串,如果需要使用預設埠8080,需確保在同一內網環境下該字串唯一且未重複使用,如果重複,啟動後可能會出現訪問埠不一致問題。

  • 啟動完客戶端後,你訪問http://abcde.vaiwan.cn/xxxxx都會對映到http://127.0.0.1:8080/xxxxx

  • 建立掃碼登入

    在本部分,你將在開發者後臺建立掃碼登入,並完成基礎配置。

    1. 登入釘釘開發者後臺

    2. 在應用詳情頁,單擊釘釘登入與分享,然後輸入回撥域名,再點選新增

      說明

      如果你還沒有域名,可以先使用配置內網穿透時設定的服務端域名,請求地址設定為/login。

    搭建後端服務

    在本部分,你將使用spring.io快速搭建服務端專案。

    1. 使用瀏覽器訪問https://start.spring.io/

    2. 根據以下操作下載服務端程式碼。

      1. 配置專案資訊。

        • Project:選擇Maven專案。

        • Language:選擇Java。

        • Packaging:選擇Jar包

        • Java:本教程選擇Java8,你可以根據自身需要選擇相應的Java版本。

      2. 單擊GENERATE

        生成專案檔案及下載。

    3. 解壓下載的專案檔案,然後使用IntelliJ IDEA開啟。

    4. 參考以下步驟,下載並匯入釘釘Java SDK。

      1. 單擊這裡下載釘釘服務端Java SDK。

      2. 解壓dingtalk-sdk-java.zip

      3. IntelliJ IDEA工具的頂部選單欄中,選擇File > Project Structure

      4. 選擇Libraries,然後單擊 + 號,在彈出的介面單擊Java。

      5. 選中下載的SDK,然後依次單擊OK > Apply完成匯入。

    5. 開啟pom.xml檔案,新增如下依賴。

      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>1.2.6</version>
      </dependency>
      一鍵複製
    6. 等待專案載入完成後,在src/main/java/com/example/demo/目錄下新建一個類LoginController.java

    7. 然後在LoginController.java中新增以下程式碼。

      • 修改getToken()方法中AppKeyAppSecret為步驟一H5微應用的AppKeyAppSecret

      • 修改appidappSecret為步驟三建立掃碼登入時建立的appidappSecret

      import com.alibaba.fastjson.JSONObject;
      import com.dingtalk.api.DefaultDingTalkClient;
      import com.dingtalk.api.DingTalkClient;
      import com.dingtalk.api.request.OapiGettokenRequest;
      import com.dingtalk.api.request.OapiSnsGetuserinfoBycodeRequest;
      import com.dingtalk.api.request.OapiUserGetbyunionidRequest;
      import com.dingtalk.api.request.OapiV2UserGetRequest;
      import com.dingtalk.api.response.OapiGettokenResponse;
      import com.dingtalk.api.response.OapiSnsGetuserinfoBycodeResponse;
      import com.dingtalk.api.response.OapiUserGetbyunionidResponse;
      import com.dingtalk.api.response.OapiV2UserGetResponse;
      import com.taobao.api.ApiException;
      import org.springframework.web.bind.annotation.*;

      @RestController
      public class LoginController {

      @RequestMapping(value = <span class="hljs-string">"/login"</span>)
      <span class="hljs-keyword">public</span> <span class="hljs-keyword">String</span> login(@RequestBody(required = <span class="hljs-literal">false</span>) JSONObject json, @RequestParam(<span class="hljs-string">"code"</span>) <span class="hljs-keyword">String</span> code) {
          <span class="hljs-keyword">try</span> {
              <span class="hljs-comment">// 獲取access_token,注意正式程式碼要有異常流處理</span>
              <span class="hljs-keyword">String</span> access_token = getToken();
      
              <span class="hljs-comment">// 通過臨時授權碼獲取授權使用者的個人資訊</span>
              DefaultDingTalkClient client2 = <span class="hljs-keyword">new</span> <span class="hljs-type">DefaultDingTalkClient</span>(<span class="hljs-string">"https://oapi.dingtalk.com/sns/getuserinfo_bycode"</span>);
              OapiSnsGetuserinfoBycodeRequest reqBycodeRequest = <span class="hljs-keyword">new</span> <span class="hljs-type">OapiSnsGetuserinfoBycodeRequest</span>();
              <span class="hljs-comment">// 通過掃描二維碼,跳轉指定的redirect_uri後,向url中追加的code臨時授權碼</span>
              reqBycodeRequest.setTmpAuthCode(code);
              <span class="hljs-comment">// 修改appid和appSecret為步驟三建立掃碼登入時建立的appid和appSecret</span>
              OapiSnsGetuserinfoBycodeResponse bycodeResponse = client2.execute(reqBycodeRequest, <span class="hljs-string">"appId"</span>, <span class="hljs-string">"appSecret"</span>);
      
              <span class="hljs-comment">// 根據unionid獲取userid</span>
              <span class="hljs-keyword">String</span> unionid = bycodeResponse.getUserInfo().getUnionid();
              DingTalkClient clientDingTalkClient = <span class="hljs-keyword">new</span> <span class="hljs-type">DefaultDingTalkClient</span>(<span class="hljs-string">"https://oapi.dingtalk.com/topapi/user/getbyunionid"</span>);
              OapiUserGetbyunionidRequest reqGetbyunionidRequest = <span class="hljs-keyword">new</span> <span class="hljs-type">OapiUserGetbyunionidRequest</span>();
              reqGetbyunionidRequest.setUnionid(unionid);
              OapiUserGetbyunionidResponse oapiUserGetbyunionidResponse = clientDingTalkClient.execute(reqGetbyunionidRequest, access_token);
              <span class="hljs-keyword">if</span> (oapiUserGetbyunionidResponse.getErrcode() == <span class="hljs-number">60121</span>L) {
                  <span class="hljs-keyword">return</span> bycodeResponse.getBody();
              }
              <span class="hljs-comment">// 根據userId獲取使用者資訊</span>
              <span class="hljs-keyword">String</span> userid = oapiUserGetbyunionidResponse.getResult().getUserid();
              DingTalkClient clientDingTalkClient2 = <span class="hljs-keyword">new</span> <span class="hljs-type">DefaultDingTalkClient</span>(
                      <span class="hljs-string">"https://oapi.dingtalk.com/topapi/v2/user/get"</span>);
              OapiV2UserGetRequest reqGetRequest = <span class="hljs-keyword">new</span> <span class="hljs-type">OapiV2UserGetRequest</span>();
              reqGetRequest.setUserid(userid);
              reqGetRequest.setLanguage(<span class="hljs-string">"zh_CN"</span>);
              OapiV2UserGetResponse rspGetResponse = clientDingTalkClient2.execute(reqGetRequest, access_token);
              System.out.println(rspGetResponse.getBody());
              <span class="hljs-keyword">return</span> rspGetResponse.getBody();
          } <span class="hljs-keyword">catch</span> (ApiException e) {
              e.printStackTrace();
              <span class="hljs-keyword">return</span> <span class="hljs-string">"-1"</span>;
          }
      }
      
      <span class="hljs-keyword">public</span> <span class="hljs-keyword">String</span> getToken() {
          <span class="hljs-keyword">try</span> {
              DefaultDingTalkClient client = <span class="hljs-keyword">new</span> <span class="hljs-type">DefaultDingTalkClient</span>(<span class="hljs-string">"https://oapi.dingtalk.com/gettoken"</span>);
              OapiGettokenRequest request = <span class="hljs-keyword">new</span> <span class="hljs-type">OapiGettokenRequest</span>();
              <span class="hljs-comment">// 填寫步驟一建立應用的Appkey</span>
              request.setAppkey(<span class="hljs-string">"AppKey"</span>);
              <span class="hljs-comment">// 填寫步驟一建立應用的Appsecret</span>
              request.setAppsecret(<span class="hljs-string">"AppSecret"</span>);
              request.setHttpMethod(<span class="hljs-string">"GET"</span>);
              OapiGettokenResponse response = client.execute(request);
              <span class="hljs-keyword">String</span> accessToken = response.getAccessToken();
              <span class="hljs-keyword">return</span> accessToken;
          } <span class="hljs-keyword">catch</span> (ApiException e) {
              <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> <span class="hljs-type">RuntimeException</span>();
          }
      }
      

      }<div class="code-copy" data-clipboard-text="import com.alibaba.fastjson.JSONObject;
      import com.dingtalk.api.DefaultDingTalkClient;
      import com.dingtalk.api.DingTalkClient;
      import com.dingtalk.api.request.OapiGettokenRequest;
      import com.dingtalk.api.request.OapiSnsGetuserinfoBycodeRequest;
      import com.dingtalk.api.request.OapiUserGetbyunionidRequest;
      import com.dingtalk.api.request.OapiV2UserGetRequest;
      import com.dingtalk.api.response.OapiGettokenResponse;
      import com.dingtalk.api.response.OapiSnsGetuserinfoBycodeResponse;
      import com.dingtalk.api.response.OapiUserGetbyunionidResponse;
      import com.dingtalk.api.response.OapiV2UserGetResponse;
      import com.taobao.api.ApiException;
      import org.springframework.web.bind.annotation.*;

      @RestController
      public class LoginController {

      @RequestMapping(value = &quot;/login&quot;)
      public String login(@RequestBody(required = false) JSONObject json, @RequestParam(&quot;code&quot;) String code) {
          try {
              // 獲取access_token,注意正式程式碼要有異常流處理
              String access_token = getToken();
      
              // 通過臨時授權碼獲取授權使用者的個人資訊
              DefaultDingTalkClient client2 = new DefaultDingTalkClient(&quot;https://oapi.dingtalk.com/sns/getuserinfo_bycode&quot;);
              OapiSnsGetuserinfoBycodeRequest reqBycodeRequest = new OapiSnsGetuserinfoBycodeRequest();
              // 通過掃描二維碼,跳轉指定的redirect_uri後,向url中追加的code臨時授權碼
              reqBycodeRequest.setTmpAuthCode(code);
              // 修改appid和appSecret為步驟三建立掃碼登入時建立的appid和appSecret
              OapiSnsGetuserinfoBycodeResponse bycodeResponse = client2.execute(reqBycodeRequest, &quot;appId&quot;, &quot;appSecret&quot;);
      
              // 根據unionid獲取userid
              String unionid = bycodeResponse.getUserInfo().getUnionid();
              DingTalkClient clientDingTalkClient = new DefaultDingTalkClient(&quot;https://oapi.dingtalk.com/topapi/user/getbyunionid&quot;);
              OapiUserGetbyunionidRequest reqGetbyunionidRequest = new OapiUserGetbyunionidRequest();
              reqGetbyunionidRequest.setUnionid(unionid);
              OapiUserGetbyunionidResponse oapiUserGetbyunionidResponse = clientDingTalkClient.execute(reqGetbyunionidRequest, access_token);
              if (oapiUserGetbyunionidResponse.getErrcode() == 60121L) {
                  return bycodeResponse.getBody();
              }
              // 根據userId獲取使用者資訊
              String userid = oapiUserGetbyunionidResponse.getResult().getUserid();
              DingTalkClient clientDingTalkClient2 = new DefaultDingTalkClient(
                      &quot;https://oapi.dingtalk.com/topapi/v2/user/get&quot;);
              OapiV2UserGetRequest reqGetRequest = new OapiV2UserGetRequest();
              reqGetRequest.setUserid(userid);
              reqGetRequest.setLanguage(&quot;zh_CN&quot;);
              OapiV2UserGetResponse rspGetResponse = clientDingTalkClient2.execute(reqGetRequest, access_token);
              System.out.println(rspGetResponse.getBody());
              return rspGetResponse.getBody();
          } catch (ApiException e) {
              e.printStackTrace();
              return &quot;-1&quot;;
          }
      }
      
      public String getToken() {
          try {
              DefaultDingTalkClient client = new DefaultDingTalkClient(&quot;https://oapi.dingtalk.com/gettoken&quot;);
              OapiGettokenRequest request = new OapiGettokenRequest();
              // 填寫步驟一建立應用的Appkey
              request.setAppkey(&quot;AppKey&quot;);
              // 填寫步驟一建立應用的Appsecret
              request.setAppsecret(&quot;AppSecret&quot;);
              request.setHttpMethod(&quot;GET&quot;);
              OapiGettokenResponse response = client.execute(request);
              String accessToken = response.getAccessToken();
              return accessToken;
          } catch (ApiException e) {
              throw new RuntimeException();
          }
      }
      

      }">

      一鍵複製

    構造掃碼登入請求

    1. 執行DemoApplication.java,啟動後端服務。

    2. 開啟瀏覽器,訪問以下地址。

      替換引數appidredirect_uri建立掃碼登入時登入應用的appId回撥域名

      https://oapi.dingtalk.com/connect/qrconnect?appid=APPID&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=REDIRECT_URI
      一鍵複製
      

      引數

      是否必填

      說明

      appid

      建立的登入應用的appid。

      response_type

      固定值為code。

      scope

      取值為snsapi_login用於釘釘容器外獲取使用者授權。

      state

      用於防止重放攻擊,開發者可以根據此資訊來判斷redirect_uri只能執行一次來避免重放攻擊。

      redirect_uri

      建立掃碼登入應用授權時填寫的回撥域名。

    3. 瀏覽器顯示如下圖。

      說明

      如果你需要將釘釘登入二維碼內嵌到自己頁面中,可以參考掃碼登入第三方網站步驟二中的方式二將釘釘登入二維碼內嵌到自己頁面中

    4. 使用手機釘釘掃描瀏覽器中的二維碼,掃描結果如下圖所示。

    5. 單擊登入網頁版三方登陸測試後,瀏覽器返回資訊如下。

      • 掃碼成員在本企業內。

      • 掃碼成員不在企業內,返回的資料格式如下。

        {
        "errcode": 0,
        "errmsg": "ok",
        "user_info": {
        "nick": "楊XX",
        "unionid": "E2Mmii4axxx",
        "dingId": "\(:LWCP_v1:\)gtEp97Mxxxgg==",
        "openid": "AzF8w80nfpiSFxxxxx",
        "main_org_auth_high_level": true
        }
        }
        一鍵複製

    恭喜

    你已完成本教程的全部內容!

    你可以通過修改訪問連結的方式實現釘釘內免登第三方網站使用釘釘賬號登入第三方網站

    例如: