current position:Home>Enterprise wechat calls an external contact to obtain the userid of the current external contact and reports (fail_no permission) error. How to solve it?

Enterprise wechat calls an external contact to obtain the userid of the current external contact and reports (fail_no permission) error. How to solve it?

2022-01-27 01:17:01 CSDN Q & A

The phenomenon and background of the problem

Get the current external contact in the call userid when , Enterprise micro background printing fail_no permission, It's like me wx.agentConfig The call was not successful , however , Look at the code , There's nothing wrong with parameters , It's strange ? I don't know how to solve . It's been stuck for two days

<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script><script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script>  methods: {    EnterpriseWeChat() {      let that = this;      console.log(this.appId, this.timestamp, this.nonceStr, this.signature);      wx.config({        beta: true, //  It has to be , otherwise wx.invoke Call form jsapi There will be problems.         debug: true, //  Turn on debugging mode , Call all api The return value of will be on the client side alert come out , To see the parameters passed in , Can be in pc End open , The parameter information will go through log play , Only in pc Only when the end is printed .        appId: "ww333fa54142e953ad", //  Required , Enterprise wechat corpID        timestamp: "1639625115", //  Required , Generate signature timestamp         nonceStr: "Gdf9XNLVQ3pTaO2H", //  Required , Generate a random string of signatures         signature: "fad4568f686ea576e8e46ed914c465401cd20723", //  Required , Signature , see   appendix -JS-SDK Use authority signature algorithm         jsApiList: ["getCurExternalContact"], //  Required , Required JS Interface list , All interfaces to be called need to be passed in       });      wx.error(function (res) {        console.log(res);        // config Information validation failure will be executed error function , If the signature expires and the verification fails , Specific error messages can be opened config Of debug Mode view , You can also go back to res View in parameters , about SPA You can update your signature here .      });      wx.ready(function () {        console.log(wx);        console.log(" Injection authorization ");        wx.agentConfig({          corpid: "ww333fa54142e953ad", //  Required , Enterprise wechat corpid, It must be consistent with the currently logged in enterprise           agentid: "(e.g. 1000017)", //  Required , Application of enterprise wechat id (e.g. 1000247)          timestamp: "1639625042", //  Required , Generate signature timestamp           nonceStr: "bWQ7kLjoVO0tJtJk", //  Required , Generate a random string of signatures           signature: "aff2ff84ac0d152158ae2148e3b06919de057aa4", //  Required , Signature , See appendix -JS-SDK Use authority signature algorithm           jsApiList: ["getCurExternalContact"], // Required , Pass in the interface name you want to use           success: function (res) {            console.log(111222);            console.log(res);            //  Callback           },          fail: function (res) {            console.log(res);            if (res.errMsg.indexOf("function not exist") > -1) {              alert(" Version too low, please upgrade ");            }          },        });        wx.invoke("getCurExternalContact", {}, function (res) {          console.log(222);          console.log(res);          if (res.errmsg == "getCurExternalContact:ok") {            userId = res.userId; // Returns the current external contact userId            console.log(666);            console.log(userId);          } else {            // Error handling           }        });        // config It will be executed after information verification ready Method , All interface calls must be in the config After the interface gets the result ,config Is an asynchronous operation of a client , So if you need to call the relevant interface when the page is loaded , The relevant interface shall be ready The function is used to ensure proper execution. . Interface called only when triggered by the user , You can call , No need to put ready Function .      });    },},created() {  this.EnterpriseWeChat()}
Operation results and error reporting contents

errmsg: "fail_no permission"

My solution ideas and tried methods

I've tried everything I can think of Baidu has also been looking for a long time , There's no way .

What I want to achieve

It can call the current external contact normally userid




Refer to the answer 1:

Take a look at the background management of enterprise wechat , Is there any authorization to open the address book




Refer to the answer 2:



Refer to the answer 3:

No authorization , There are also fields to get values

img




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270116586612.html

Random recommended