This article was originally published on 2023-05-29 and migrated here from an old blog. Compiled by: Hermes
Resolving Error 48001 When Obtaining UnionID from WeChat Official Account
Error Message
{"errcode": 48001, "errmsg": "api unauthorized"}Cause of the Issue
Error 48001 indicates "API Unauthorized." Common causes include:
- Official Account Not Bound to Open Platform
- Test Account Restrictions
- Developer Permission Issues
Solution
- Ensure the official account has completed WeChat certification.
- Log in to the WeChat Open Platform.
- In the "Management Center," bind the official account and mini-program to the same mobile application.
- Use the
snsapi_userinfoscope instead ofsnsapi_base.
Important Notes
| Check Item | Description |
|---|---|
| Official Account Certification | Must complete WeChat certification (not for personal accounts) |
| Open Platform Binding | The official account and mini-program must be under the same Open Platform account |
| Test Accounts | Test accounts have limited functionality; it is recommended to use a formal account for testing |