search
HomeWeChat AppletMini Program DevelopmentDetailed explanation of WeChat mini program login process

This article mainly explains in detail the relevant information about the WeChat Mini Program login process. Friends who need it can refer to

WeChat Mini Program Login Process

##1 :What are session_key and openId? session_key

The official description is:


session_key is the key generated by the WeChat

service server to encrypt and sign user data

Purpose of session_key


(1) Decrypt the "ciphertext in user information" obtained by wx.getUserInfo()

interface. (2) "Process it slightly" and use it to maintain the login state of the applet.

"A little processing" is roughly as follows:


(1) Generate a random number (officially called it 3rd_session)

(2) Treat this random number as The key of session, session_key + openid is value.

That is: session[3rd_session]=session_key+openid

openIdopenId: the user’s unique identifier


That is: each WeChat user in your mini program unique identifier.

Detailed explanation of WeChat mini program login process

2: How to obtain session_key and openId. The official HTTP interface is provided:


https:// api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code

Getting steps:


(1) Get appid, secret, js_code

(2) Replace the APPID, SECRET, and JSCODE of the above interface address with appid, secret, and js_code respectively. Leave the others unchanged and assemble them into a complete address.

For example:


Detailed explanation of WeChat mini program login process

3: In "Open this address in the browser" or "Simulate the browser in the background" GET executes this address" to return the following JSONdata (including openid, sessionkey)

WeChat applet obtains session_key and openId (encryption, decryption, signature series)

Summary: It can be seen from steps 1, 2, and 3 that as long as you get the appid, secret, and js_code, you can get the session_key and openId

Detailed explanation of WeChat mini program login process

4: Obtain appid and secret

appid is the applet ID


secret is the applet key (AppSecret)


How to obtain: Mini program backend login URL: https://mp.weixin.qq.com/

After opening the mini program backend URL, register, and log in, you can find yours as shown below AppID and AppSecret.

The WeChat mini program obtains session_key and openId (encryption, decryption, signature series)

Note: Currently, individuals cannot register for the mini program, and the scope of open registration is: enterprises, governments, media, and other organizations; of course, use This way, individuals can also register.


Portal: http://www.wxapp-

union.com/forum.php?mod=viewthread&tid=495

5: How to obtain js_code by calling the wx.login() interface to obtain the login credentials (js_code)

WeChat applet obtains session_key and openId (encryption, decryption, signature series)

Detailed explanation of WeChat mini program login process

6: Summarize the entire session_key acquisition process

(1) Register for the WeChat applet, log in to the background and obtain the appId and secret in the settings (Key)

(2) Call the wx.login() interface to obtain the login credentials js_code
(3) Call the wx.request() interface to send the js_code to the server background
(4) In the server background, Known appId, secret, js_code

and then call the following official http interface, you can return to get openId, session_key

The official http interface address is:


https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code

Thank you for reading, I hope it can help everyone, thank you for your interest in this site support!


The above is the detailed content of Detailed explanation of WeChat mini program login process. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools