微信"errcode":40163,"errmsg":"code been used錯誤原因及解決方法

在做微信公衆平臺網頁授權時,發現每次請求授權鏈接

https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=xxx&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect

時都會重定向鏈接redirect_uri都會自動請求兩次,由於併發導致了一些問題,

{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest, hints: [ req_id: PSp.LA0036s182 ]"}

那麼,爲什麼會請求兩次呢?,調試時發現會訪問兩次,一次是301,頁面重定向了,第二次跟第一次就差這個參數。加上後,不再報錯。code 可以了。

後來發現只要加個屬性就不會有這個問題了。

https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=xxx&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect

&connect_redirect=1 這個參數

微信支付獲取用戶openid時,報出錯誤。原因是同時配置了http和https,微信網頁oauth認證通知了兩次
刪除apache配置文件中http保留https,原因嘛就是微信通知2017-12-31日前微信開發必須使用https。

bug是在配置https以後出現的,這個提示讓我最終找到了原因。



最新更新:要麼用https,要麼用服務器端的緩存,當處理過這個code ,不再重複處理 ,直接拒絕

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章