Answer the question
In order to leave comments, you need to log in
How to implement "Sign in with VK" on Parse.com?
Pars recently announced Third-Party Authentication support for web apps blog.parse.com/2014/01/14/adding-third-party-authe...
They even have an example for GitHub https://github.com/ParsePlatform /CloudCodeOAuthGit...
Also, a new method for PFUser appeared in the Client SDK:
[PFUser becomeInBackground:@"session-token-here" block:^(PFUser *user, NSError *error) {
if (error) {
// The token could not be validated.
} else {
// The current user is now set to user.
}
}];
Answer the question
In order to leave comments, you need to log in
The code for parse cloud looks for a user with a given vkId and returns a token
Parse.Cloud.define("getTokenByVkId", function(request, response) {
Parse.Cloud.useMasterKey();
var vkId = request.params.vkId;
if(!vkId) {
response.error("wrong parameters");
return ;
}
var query = new Parse.Query(Parse.User);
query.equalTo("vkId", vkId);
query.first({
success: function(user) {
response.success(user.getSessionToken());
},
error: function(error) {
response.error(error.description);
}
});
});
//call parse cloud function
[PFCloud callFunctionInBackground:@"getTokenByVkId"
withParameters:@{@"vkId": vkUserId}
block:^(NSString* token, NSError *error) {
if (!error){
[PFUser becomeInBackground:token block:^(PFUser *user, NSError *error) {
<#code#>
}];
}else{
//TODO: handle error
}
You yourself answer your own question, giving an example implementation for Github. :) Take this code and edit even under VK, even under Google+.
There is a link on the github to a detailed manual:
https://parse.com/tutorials/adding-third-party-aut...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question