微信公眾平台網頁授權兩次重定向跳轉問題


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

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 這個參數

主要是微信開發者文檔里沒提到這個參數:1 第一步:用戶同意授權,獲取code


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM