parse.com - How to OAuth using WeChat Login for Parse Server -
we enable wechat login on our ios client connected parse server backend on heroku. reading through pffacebookauthenticationprovider, seems need write custom authentication provider wechat.
wechat login based on oauth 2.0. works followed: 1. our app, authorization request sent wechat app installed on same phone. wechat app called foreground. 2. after user approved authorization request, code (not access token) sent our app. 3. code , our app id , app secret, our server can call wechat api , appropriate user id , access token wechat. step has happen on our server, cannot include app secret within our client app.
on wechat documentation, recommended keep access token strictly in control of server (anyone access token can make requests wechat api , counted towards usage limit our api calls).
if follow practice, cannot save access token in authdata field of user. acceptable save code , id wechat authdata , save access token class master key has access to? requires write custom authadapter parse server.
or there better way implement custom auth? custom auth documentation parse server pretty thin , plan improve after can working myself.
you can update auth adapter exchange code access token server side. logic similar other adapters, failing login/signup if server unable process code access token exchange.
here https://github.com/parse-community/parse-server/blob/master/src/adapters/auth/wechat.js#l7
if authdata object has code, can add additional logic exchange it.
Comments
Post a Comment