Skip to content

Instantly share code, notes, and snippets.

@flovilmart
Created February 17, 2016 12:46
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save flovilmart/68a6c538496953408bb1 to your computer and use it in GitHub Desktop.
Save flovilmart/68a6c538496953408bb1 to your computer and use it in GitHub Desktop.
Authenticate with custom OAuth example
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
}
@maravilhosinga
Copy link

Hi, for android how can i implement this ???

@kesongxie
Copy link

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