static void TestGetUserInfo(string[] args) { // Step 1 - Defining the request string method = "socialize.getUserInfo"; GSRequest request = new GSRequest(apiKey, secretKey, method, true); // Step 2 - Adding parameters request.SetParam("uid", "di1"); // set the "uid" parameter to user's ID request.SetParam("enabledProviders", "*,testnetwork,testnetwork2"); request.SetParam("status", "I feel great 22222"); // set the "status" parameter to "I feel great" // Step 3 - Sending the request GSResponse response = request.Send(); bool validate = SigUtils.ValidateUserSignature( response.GetString("UID", ""), response.GetString("signatureTimestamp", ""), secretKey, response.GetString("UIDSignature", "")); // Step 4 - handling the request's response. if (response.GetErrorCode() == 0) { // SUCCESS! response status = OK Console.WriteLine("Success in setStatus operation."); } else { // Error Console.WriteLine("Got error on setStatus: {0}", response.GetErrorMessage()); } }
private void verifyResponseSignature(GSResponse res, string format) { if (!format.Equals("xml", StringComparison.InvariantCultureIgnoreCase)) { GSObject data = res.GetData(); if (null != data) { if (cbMethods.Text.IndexOf("getUserInfo", StringComparison.InvariantCultureIgnoreCase) > -1) { string uid = data.GetString("UID", ""); string uidSig = data.GetString("UIDSignature", ""); string sigTimestamp = data.GetString("signatureTimestamp", ""); if (SigUtils.ValidateUserSignature(uid, sigTimestamp, txtSecKey.Text, uidSig)) { lblVerifiedSig.Text = "Signature is verified"; lblVerifiedSig.ForeColor = Color.Green; } else { lblVerifiedSig.Text = "Invalid signature !!!"; lblVerifiedSig.ForeColor = Color.Red; } } if (cbMethods.Text.IndexOf("getFriendsInfo", StringComparison.InvariantCultureIgnoreCase) > -1) { GSArray friends = data.GetArray("friends"); if (null != friends && friends.Length > 0) { GSObject firstFriend = friends.GetObject(0); string friendSig = firstFriend.GetString("friendshipSignature"); string tsSig = firstFriend.GetString("signatureTimestamp"); string friendUID = firstFriend.GetString("UID"); if (SigUtils.ValidateFriendSignature(txtUID.Text, tsSig, friendUID, txtSecKey.Text, friendSig)) { lblVerifiedSig.Text = "1ST friend's signature is verified"; lblVerifiedSig.ForeColor = Color.Green; } else { lblVerifiedSig.Text = "Invalid signature (1ST friend's) !!!"; lblVerifiedSig.ForeColor = Color.Red; } } } } } }
public bool ValidateSignature(string userId, IGigyaModuleSettings settings, GSResponse response, bool disableSignatureExchange = false) { return(SigUtils.ValidateUserSignature(userId, response.GetString(Constants.GigyaFields.SignatureTimestamp, null), settings.ApplicationSecret, response.GetString(Constants.GigyaFields.UserIdSignature, null))); }
public Task <bool> ValidateUIDSignature(string UID, string timestamp, string signature) { int iTimeStamp = (int)(System.DateTime.Parse(timestamp).Subtract(new System.DateTime(1970, 1, 1))).TotalSeconds; return(Task.FromResult <bool>(SigUtils.ValidateUserSignature(UID, iTimeStamp.ToString(), secretKey, signature))); }