当前位置:网站首页>FinClip实现微信授权登录的三种方案
FinClip实现微信授权登录的三种方案
2022-07-25 05:17:00 【finogeeks】
随着微信这款国民级应用月活突破12亿,越来越多用户倾向于选择微信作为全网登录账号,因此微信授权登录被许多APP、小程序作为第三方登录授权的首选。在微信小程序下,小程序登录功能一般会通过 OpenID 或 UnionID 作为唯一标识,与小程序服务的账号体系进行关联打通,完成用户账户体系的构建与设计。
目前FinClip作为在App中运行小程序的主流方案,对于从微信小程序环境迁移到 FinClip 下的小程序具有快速复用微信登录流程,以及实现微信授权登录的需求。本文着重为大家分享,在 FinClip环境下,小程序实现微信授权登录的几种方案。
为什么小程序需要关联微信登录?
首先来谈一谈小程序需要关联微信登录的原因:如果开发者选择先将开发的小程序上架到微信,可以调用 wx . login 获取用户身份,快速建立小程序的用户体系。此后如果想要迁移小程序到其他 App ,账户体系面临重建,之前积累的微信用户想要引导接入其他平台,使用原微信账号登录会非常不方便。使用 FinClip 关联微信登录后,可以快速复用微信登录逻辑,授权获取微信账号信息,帮助企业快速从微信向自建生态引流。
FinClip实现微信授权登录的三种方案
方案一:服务端改造
适用场景:平台方通过 FinClip 构建自有生态,FinClip 环境中运行的都是第三方的小程序(即平台方无法修改小程序代码)。
- 第一步:在 App 中通过自定义 API 注入 wx.login 方法,按照微信小程序的格式返回 code;
- 第二步:小程序无需改动,按照在微信端的实现,此时会将 code 发送给开发者的服务器;
- 第三步:开发者服务器进行适配,通过 code可判断登录来自 FinClip 平台,从 code 中解析出 UserID,返回自身账户体系的内容即可。
方案二:服务端改造(唤起微信授权)
使用场景:平台方通过 FinClip 完成自身功能的拆分,小程序都由平台方自己开发(即平台方可以修改小程序代码)。
- 第一步:SDK 中集成微信开发平台 SDK;
- 第二步:使用自定义 API 注入 wx.login,唤起微信授权后即可取得返回 code,此时可能需要对 code 拼接唯一标识;
- 第三步:小程序无需改动,按照在微信端的实现,此时会将 code 发送给开发者的服务器;
- 第四步:服务端根据 code 唯一标识,调用不同的授权接口取得 OpenID,查询登录态返回;
限制:由于微信限制不同主体,不同开放平台下的 OpenID 是不一致的,此时小程序需要关联到同一主体,或者同一开放平台(此时唯一标识为 UnionID)。
方案三:小程序改造
适用场景:对小程序进行逻辑修改,当判断 FinClip 环境中时,直接从 wx.login 中获取需要的信息(即平台方可以修改小程序代码)。
APP 使用自定义 API 注入 wx.login ,返回当前 APP 用户的登录态即可。
三种场景里,这种方法操作稍微复杂一些,需要在已有微信小程序中进行定义修改,从而使得 FinClip 小程序具备微信登录的能力,具体操作流程可以参考官方文档:微信登录功能介绍
实现效果如下:
FinClip微信授权登录的实现效果
小程序生成app也可轻松实现微信授权登录
熟悉FinClip的都知道,除了在自有App中跑小程序之外。通过FinClip 提供的FIDE还能把微信小程序生成APP,对于一些开发能力比较弱的公司,或者APP功能要求简单的项目非常的快捷实用,具体教程大家可以点击开发文档查看:小程序生成 App
对于这种通过小程序转的app,也同样可以实现微信授权登录,方法如上。
最近我看到FinClip 已经推出了SAAS版本,功能非常全,每月有10000次免费发布调用,对于我们个人开发者来说,这个免费调用量已经足够了,超出部分购买流量包也非常便宜,基本是打骨折的地步了。感兴趣可以去官网看看。
边栏推荐
- Implementation of recommendation system collaborative filtering in spark
- 956. Highest billboard pressure DP
- [the most comprehensive and detailed] how to design a database and table splitting scheme that can dynamically expand and shrink capacity?
- [small program practice] first day
- Implement is by yourself_ class
- Xiaohongshu joins hands with HMS core to enjoy HD vision and grow grass for a better life
- STM32 Development Notes 118: using CMSIS DSP Library in stm32cube IDE
- This low code reporting tool is needed for data analysis
- Redis cluster setup (Windows)
- Small case of data analysis: visualize recruitment data and view the most needed technologies in the field~
猜你喜欢

自己实现is_base_of

Now the operator wants to check the answer details of all user questions from Zhejiang University. Please take out the corresponding data

Delivery practice of private PAAS platform based on cloud native

初步了解Panda3d粒子系统
![[wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)](/img/01/42de6280191b9c32a7f37d7727bd4f.png)
[wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)

1310_ Implementation analysis of a printf

Compile ue5.0

Permanent magnet synchronous motor 36 question (1) -- what is the difference between salient pole motor and salient pole motor?

自己实现is_class

Browser cache HTTP cache CDN cache localstorage / sessionstorage / cookies
随机推荐
Panda3D keyboard moving scene
Thesis reading | which is the best multilingual pre training technology for machine translation? See the latest progress!
Which side of Nacos has the SQL script of this column?
Matter's Unified Smart Home connection standard enables local automatic interaction between smart devices
Introduction to CpG control network
956. Highest billboard pressure DP
How to carry out the function test with simple appearance and complex interior?
STL notes (I): knowledge system
Project management tool - Introduction and practice of Alibaba cloud projex
[literature notes] pointmlp
LCP插件创建对等VLAN接口
Oracle split branches
300. Longest increasing subsequence
The third day of rhcsa summer vacation
教你如何定位不合理的SQL?并优化之
JS common code questions array de duplication - Custom New throttling and anti shake - deep copy - instanceof URL parameter extraction - thousand separator - array to tree structure - array flattening
2022-7-15 summary
Seven suggestions for Server Protection
Delivery practice of private PAAS platform based on cloud native
Introduction to kubernetes