iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何使用OAuth在Parse iOS SDK中验证用户?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
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中验证用户?所遇到的程序开发问题。

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。