Created
February 17, 2016 12:46
-
-
Save flovilmart/68a6c538496953408bb1 to your computer and use it in GitHub Desktop.
Authenticate with custom OAuth example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Parse | |
import Bolts | |
class AuthDelegate:NSObject, PFUserAuthenticationDelegate { | |
func restoreAuthenticationWithAuthData(authData: [String : String]?) -> Bool { | |
return true | |
} | |
} | |
let configuration = ParseClientConfiguration { (configuration) -> Void in | |
configuration.server = "http://localhost:1337/" // URL to your parse server | |
configuration.applicationId = "12345" // your application ID | |
configuration.clientKey = "12345" // your client key | |
} | |
Parse.enableLocalDatastore() | |
Parse.initializeWithConfiguration(configuration) | |
Parse.setLogLevel(PFLogLevel.Debug) | |
// Create an authenitcation delegate to validate auth data to be restored | |
let authDelegate = AuthDelegate() | |
// Register the authentication delegate | |
PFUser.registerAuthenticationDelegate(authDelegate, forAuthType: "twitter") | |
// Fill the auth data with the response of the Twitter SDK | |
let authData = ["auth_token":"AUTH_TOKEN", | |
"auth_token_secret":"AUTH_TOKEN_SECRET", | |
"id":"USER_ID", | |
"screen_name":"USER_SCREEN_NAME"] | |
PFUser.logInWithAuthTypeInBackground("twitter", authData: authData).continueWithBlock { (task) -> AnyObject? in | |
// the PFUser currentUser should not be nil at this point | |
return nil | |
} |
Where can I find the corresponding key for the authData required for Spotify login? I tried to search the web but could not find any useful information about login with Spotify
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, for android how can i implement this ???