1, create a class that comes from both NSObject and PFUserAuthenticationDelegate.
class AuthDelegate:NSObject, PFUserAuthenticationDelegate { func restoreAuthenticationWithAuthData(authData: [String : String]?) -> Bool { return true } }
2, register this authentication delegate
// 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 using the PFUser.logInWithAuthTypeInBackground method to store user information in _User
// for google oauth, authData format will be // ["id":"PUT_USER_ID_HERE","accesstoken":"PUT_TOKEN_HERE"] PFUser.logInWithAuthTypeInBackground("google", authData:[.....])
4, you will see that the record is created in _User, only with the lens and authData p>
source share