Home > Article > Backend Development > How to enable a WeChat third party to initiate web page authorization on behalf of a public account
The main content of this article is to introduce how to implement web page authorization initiated by a WeChat third party on behalf of a public account. It has certain reference value and I hope it can be helpful to you.
Purpose: Web page authorization
Prerequisite:
The official account or mini program must be authorized to a third-party platform,
It is included in the interface permissions of the official account Web page authorization must be set up
①Authorization: I won’t go into details here
②Web page authorization domain name designation:
WeChat public platform-> interface Permissions->Web Service->Web Authorization-> Modify ->Web page authorization domain name settings-->Directly write the login authorization initiation page of the third-party server Just a domain name is enough, no need to specify a specific path.
Note that if the domain name of the authorized third-party server is not written here, it will be reported that scope does not have permission
Process: Open the specified link through the client to obtain the code,Use code in exchange for access_token, use access_token in exchange for user basic information
Since you need to use the client, you need to perform the following operations in the background of the official account:
① Binding (this is necessary when testing locally)
②Download Tool
Note: The following operations are for public accounts that have been authorized to third-party platforms
Binding: WeChat Public Platform-->Developer Tools -->webDeveloper tools-->Bind developer WeChat account
Download tool: Go to the official website and download one "微信webDeveloper Tools"
微信webUse of development tools:
Open WeChat developer tools -->Public account web project -->Click on the personal center of the avatar in the upper left corner and click on the small circle-->After scanning, the WeChat interface on your mobile phone will appear like this: Do you want to confirm? Log in to WeChat web Developer Tools. Testers and developers can obtain your relevant information through the following official account [the official account that has been bound to the developer in the previous step] --->Confirm login
After confirming successful login on your mobile phone, return to the WeChat developer tools and directly search in the top search box of the tool Enter the request code for the request url, similar to this:
Original link for web page authorization:
https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx1fb168c116d58358&redirect_uri=http://tzs.backend.wsjtq.com/api/wxopen/public-accounts-authorize&response_type=code&scope=snsapi_userinfo&state=888&component_appid= wxe719c0a8a906cb84#wechat_redirect
The appid in the path is the official account authorized to a third partyappid
Component_appid is the third party’sappid
Related tutorials: WeChat Mini Program Video Tutorial
The above is the detailed content of How to enable a WeChat third party to initiate web page authorization on behalf of a public account. For more information, please follow other related articles on the PHP Chinese website!