Skip to content

Instantly share code, notes, and snippets.

@PLyczkowski
Created January 27, 2019 11:17
Show Gist options
  • Save PLyczkowski/6a56d54aa18d363b00ece83123e64228 to your computer and use it in GitHub Desktop.
Save PLyczkowski/6a56d54aa18d363b00ece83123e64228 to your computer and use it in GitHub Desktop.
func login_with_email(email:String, password_hashed:String):
var data = {}
data["Email"] = email
data["Password"] = str(password_hashed)
data["TitleId"] = title_id
var http_request = HTTPRequest.new()
http_request.name = "LoginWithEmail"
http_request.connect("request_completed", self, "_login_with_email_completed", [http_request])
add_child(http_request)
http_request.request(
"https://"+title_id+".playfabapi.com/Client/LoginWithEmailAddress",
["Content-Type: application/json"],
true,
HTTPClient.METHOD_POST,
to_json(data)
)
func _login_with_email_completed(result, response_code, headers, body, http_request):
print("Login with email completed. Response:")
var dict:Dictionary = parse_json(body.get_string_from_utf8())
print(dict)
# Get user and session data
if dict.has("data"):
prints("[PlayFab API] Login succeeded")
play_fab_id = dict.data.PlayFabId
user_session_ticket_value = dict.data.SessionTicket
user_last_login_time = dict.data.LastLoginTime
else:
prints("[PlayFab API] Login failed")
http_request.queue_free()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment