4
解析服務器提供OAuth身份驗證。我該如何使用Parse Server的預定義OAuth模塊,例如Facebook,註冊一個新用戶或登錄'_User'類的現有用戶?如何使用OAuth在Parse iOS SDK中對用戶進行身份驗證?
解析服務器docs舉例說明如何配置OAuth模塊。但是,如何在iOS項目中使用它來登錄或註冊用戶?
解析服務器提供OAuth身份驗證。我該如何使用Parse Server的預定義OAuth模塊,例如Facebook,註冊一個新用戶或登錄'_User'類的現有用戶?如何使用OAuth在Parse iOS SDK中對用戶進行身份驗證?
解析服務器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,你會看到一個記錄被創建_用戶,只有objectId和authData
我找不到有關第三方lo的任何有用信息杜松子酒與解析。我想知道我是否也可以與Spotify登錄集成? –
@KesongXie你可以在這裏看到支持的提供商https://github.com/parse-community/parse-server/tree/master/src/Adapters/Auth – hhanesand