2016-05-16 50 views

回答

6

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

+0

我找不到有關第三方lo的任何有用信息杜松子酒與解析。我想知道我是否也可以與Spotify登錄集成? –

+1

@KesongXie你可以在這裏看到支持的提供商https://github.com/parse-community/parse-server/tree/master/src/Adapters/Auth – hhanesand

相關問題