{"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}
{"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}
֤ķ
ѽ
ǰ˵
ҳȨȡûϢ scope
https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope={2}&state=ok#wechat_redirect
snsapi_base Ҫûͬ⣬ֱתȨҳ棬ֻڻȡopenidܻȡûϢ
snsapi_userinfo ûͬ⣬ȨԻȡûϢ
Ϊ˷⣬ѽӿڷصչʾ°
{
"access_token":"YNTxefBAfNW565Q4MAI..................j-hLNzin9Vq6BnvcvJ8NKHdBSRhkLjHQliLiNQc",
"expires_in":7200,
"refresh_token":"EYmfmvUg0PGtOWiLpb..................T8O2UyKL95_Da23fLV-nYFDgnt14Ljl_x_zCMY",
"openid":"oYbGRs8MmU6bESxXcX2Z0rFRivjQ",
"scope":"snsapi_base"
}
{
"access_token":"IdFXvRMq3J6vXUcZ0iQ..................G1xbkGJEnbnSKQ4G0nyQ5vmNSKF4a4DzGu64",
"expires_in":7200,
"refresh_token":"J8ot4JWphxwvyAY3I9r..................krET6P-8dot_-_tQfFoLUQI3EI-NT-I-degNRGumA",
"openid":"oYbGRs8MmU6bESxXcX2Z0rFRivjQ",
"scope":"snsapi_userinfo"
}
1 ״ʹ scope=snsapi_base ҳȨ
2 õ code ýӿ https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code
3 һȡ openid access_token ýӿ https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN ȡûϢ
4 ȡʧܣ {"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}
ʧԭ
scope=snsapi_base ʱֻڻȡopenidܻȡûĻϢȡûϢҪûͬ⡣scope=snspai_base ȨʱûûͬȨһ
ʱɹʱʧܣ
ΪʲôеʱһںţIJ裬ܳɹȡûĻϢ
48001,api unauthorized֮úܶԻ⣬
ֱϽʽ˵ԭ
ʹ scope=snsapi_userinfo һҳȨ桾֡һɹȡûŻϢ
ʹ scope=snsapi_base ظһ顾֡γɹˣ
ԭ
ʵʵѾ˵ԭˣЩһⲻˣ
һʹ scope=snsapi_baseDzҪûͬȨܻȡûĻϢ
ڶʹ scope=snsapi_userinfoҪûͬȨܻȡûĻϢ
ʹ scope=snsapi_userinfoûͬȨһʱڣҪûͬ⣬ҲԻȡûϢʱʹ scope=snsapi_base ҲܻȡûϢopenidֵûϵǿոΪգ
ע
ʹ scope=snsapi_userinfoûͬȨaccess_token Ч7200루Сʱ
access_token ʧЧʹ refresh_token ýӿ https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type=refresh_token&refresh_token={1} »ȡ access_tokenЧ7200룩
֪ refresh_token Ǹõ˰ɣ
refresh_token Ч30죬ûͬȨ30ڣҪûͬȨͿԻȡûϢ