Sign In Register

How can we help you today?

Start a new topic
Answered

Calling Cloud Code from REST API?

hi,


I am studying the docs for the REST API, but am struggling to find out how to accomplish something.


I'm looking to see how to call Cloud Code from the REST API. Is this possible?


What I'd like to do specifically is allow users to reset their password if they forgot it. So I'm following the Guide which shows how to email the user a link which contains the unique token ID.


I would like to create a web page which allows the user to enter a new password, which then calls the Cloud Code/RESTAPI which resets the password on the player object to the new value they selected.


Thank you for any help!


Drew


Best Answer

Hi Drew,


For a Password reset system like this I would recommend making use of Callbacks


In this scenario, when you check an e-mail it will have a unique code embedded into it identifying that password reset request. When the user enters their new password and clicks submit on the web form, it would hit a callback url with the unique code (and any other information you would like to use to identify the player). The Cloud Code in this callback would then verify the unique code, the player, then load the player into a SparkPlayer object and change the password via setPassword.


Does this seem like a good solution?


-Pádraig


Answer

Hi Drew,


For a Password reset system like this I would recommend making use of Callbacks


In this scenario, when you check an e-mail it will have a unique code embedded into it identifying that password reset request. When the user enters their new password and clicks submit on the web form, it would hit a callback url with the unique code (and any other information you would like to use to identify the player). The Cloud Code in this callback would then verify the unique code, the player, then load the player into a SparkPlayer object and change the password via setPassword.


Does this seem like a good solution?


-Pádraig


1 person likes this

Thanks Padraig, this was exactly what I was looking for!


I have another question - is there a way for me to validate an AuthToken given to me by GameSparks when I log the player in?


What I'd like to do is create a service outside of GameSparks which does certain things. But I want to integrate with GameSparks as well. In order for this to work, I need to be able to re-use the authentication scheme that GameSparks uses. 


Is there some way to validate an AuthToken that GameSparks gives me from inside my app? (EG, a WebAPI call or SDK call?)

Is there some way to get the UserID and other user info about the user from a given Auth Token via A WebAPI or SDK call?


Thank you!

Login to post a comment