如何使用OAuth在Parse iOS SDK中验证用户?

如何使用OAuth在Parse iOS SDK中验证用户?,第1张

概述Parse Server提供OAuth身份验证.如何使用Parse Server的预定义OAuth模块,例如Facebook,注册新用户或登录’_User’类的现有用户? Parse Server docs提供了有关如何配置OAuth模块的示例.但是如何在iOS项目中使用它来登录或注册用户? 1,创建一个从NSObject和PFUserAuthenticationDelegate扩展的类. cla Parse Server提供OAuth身份验证.如何使用Parse Server的预定义OAuth模块,例如Facebook,注册新用户或登录’_User’类的现有用户?

Parse Server docs提供了有关如何配置OAuth模块的示例.但是如何在iOS项目中使用它来登录或注册用户?

解决方法 1,创建一个从NSObject和PFUserAuthenticationDelegate扩展的类.

class AuthDelegate:NSObject,PFUserAuthenticationDelegate {    func restoreAuthenticationWithAuthData(authData: [String : String]?) -> Bool {        return true    }}

2,注册此身份验证委托

// parmeter 'forAuthType' is the name of file defined in // https://github.com/parse-community/parse-server/blob/master/src/Adapters/Auth/index.Js// such as: Google,github,linkedin ......PFUser.registerauthenticationDelegate(AuthDelegate(),forAuthType: "Google")

3,使用PFUser.logInWithAuthTypeInBackground方法将用户信息存储到_User

// for Google oauth,authData format will be// ["ID":"PUT_USER_ID_HERE","accesstoken":"PUT_TOKEN_HERE"]PFUser.logInWithAuthTypeInBackground("Google",authData:[.....])

4,您将看到在_User中创建的记录,只有objectID和authData

总结

以上是内存溢出为你收集整理的如何使用OAuth在Parse iOS SDK中验证用户?全部内容,希望文章能够帮你解决如何使用OAuth在Parse iOS SDK中验证用户?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1072925.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-26
下一篇2022-05-26

发表评论

登录后才能评论

评论列表(0条)

    保存