// SOCIAL MEDIA VERIFICATION FUNCTION__________________________________ // SOCIAL MEDIA TOKEN UPDATE FUNCTION__________________________________ // This function updates social media user' access and refresh tokens. async Task <bool> UpdateAccessRefreshToken(string id, string accessToken, string refreshToken) { bool result = false; try { var client = new HttpClient(); UpdateTokensPost updateTokesPost = new UpdateTokensPost(); updateTokesPost.uid = id; updateTokesPost.mobile_access_token = accessToken; updateTokesPost.mobile_refresh_token = refreshToken; var updateTokesPostSerializedObject = JsonConvert.SerializeObject(updateTokesPost); var updateTokesContent = new StringContent(updateTokesPostSerializedObject, Encoding.UTF8, "application/json"); var updateTokesResponse = await client.PostAsync(Constant.UpdateTokensUrl, updateTokesContent); if (updateTokesResponse.IsSuccessStatusCode) { result = true; Debug.WriteLine("UPDATING ACCESS AND REFRESH TOKENS WAS SUCESSFULLY"); } else { Debug.WriteLine("ERROR UPDATING ACCESS AND REFRESH TOKENS"); } } catch { } return(result); }
private async void GoogleAuthenticatorCompleted(object sender, AuthenticatorCompletedEventArgs e) { var authenticator = sender as OAuth2Authenticator; if (authenticator != null) { authenticator.Completed -= GoogleAuthenticatorCompleted; authenticator.Error -= GoogleAuthenticatorError; } if (e.IsAuthenticated) { if (accessToken == null && refreshToken == null) { accessToken = e.Account.Properties["access_token"]; refreshToken = e.Account.Properties["refresh_token"]; Application.Current.Properties["access_token"] = accessToken; Application.Current.Properties["refresh_token"] = refreshToken; GoogleUserProfileAsync(accessToken, refreshToken, e); } if (!refreshToken.Equals(e.Account.Properties["refresh_token"]) && !accessToken.Equals(e.Account.Properties["access_token"])) { DateTime today = DateTime.Now; DateTime expirationDate = today.AddDays(Constant.days); Application.Current.Properties["time_stamp"] = expirationDate; accessToken = e.Account.Properties["access_token"]; refreshToken = e.Account.Properties["refresh_token"]; UpdateTokensPost updateTokens = new UpdateTokensPost(); updateTokens.access_token = accessToken; updateTokens.refresh_token = refreshToken; updateTokens.uid = (string)Application.Current.Properties["uid"]; updateTokens.social_timestamp = expirationDate.ToString("yyyy-MM-dd HH:mm:ss"); var updatePostSerilizedObject = JsonConvert.SerializeObject(updateTokens); var updatePostContent = new StringContent(updatePostSerilizedObject, Encoding.UTF8, "application/json"); var client = new HttpClient(); var RDSrespose = await client.PostAsync(Constant.UpdateTokensUrl, updatePostContent); if (RDSrespose.IsSuccessStatusCode) { GoogleUserProfileAsync(accessToken, refreshToken, e); } else { System.Diagnostics.Debug.WriteLine("Unable to update google tokens"); } } } else { await DisplayAlert("Error", "Google was not able to autheticate your account", "OK"); } }
public async void OnAppleSignInRequest() { var account = await appleSignInService.SignInAsync(); if (account != null) { Preferences.Set(App.LoggedInKey, true); await SecureStorage.SetAsync(App.AppleUserIdKey, account.UserId); // System.Diagnostics.Debug.WriteLine($"Signed in!\n Name: {account?.Name ?? string.Empty}\n Email: {account?.Email ?? string.Empty}\n UserId: {account?.UserId ?? string.Empty}"); var client = new HttpClient(); var socialLogInPost = new SocialLogInPost(); if (apple_token == null && apple_email == null) { apple_token = account.Token.Substring(0, 500); apple_email = account.Email; AppleUserProfileAsync(apple_token, apple_email, account.Name); } if (!apple_token.Equals(account.Token) && apple_token != null) { DateTime today = DateTime.Now; DateTime expirationDate = today.AddDays(Constant.days); Application.Current.Properties["time_stamp"] = expirationDate; apple_token = account.Token.Substring(0, 500); UpdateTokensPost updateTokens = new UpdateTokensPost(); updateTokens.access_token = apple_token; updateTokens.refresh_token = apple_token; updateTokens.uid = (string)Application.Current.Properties["uid"]; updateTokens.social_timestamp = expirationDate.ToString("yyyy-MM-dd HH:mm:ss"); var updatePostSerilizedObject = JsonConvert.SerializeObject(updateTokens); var updatePostContent = new StringContent(updatePostSerilizedObject, Encoding.UTF8, "application/json"); var RDSrespose = await client.PostAsync(Constant.UpdateTokensUrl, updatePostContent); if (RDSrespose.IsSuccessStatusCode) { AppleUserProfileAsync(apple_token, apple_email, string.Empty); } else { System.Diagnostics.Debug.WriteLine("We were not able to update your APPLE token"); } } } else { AppleError?.Invoke(this, default(EventArgs)); } }
public async void FacebookAuthenticatorCompleted(object sender, AuthenticatorCompletedEventArgs e) { if (e.IsAuthenticated) { // KEYS: access_token, data_access_expiration_time, expires_in, state if (accessToken == null && refreshToken == null) { accessToken = e.Account.Properties["access_token"]; refreshToken = accessToken; FacebookUserProfileAsync(accessToken); } if (!refreshToken.Equals(e.Account.Properties["access_token"]) && !accessToken.Equals(e.Account.Properties["access_token"])) { DateTime today = DateTime.Now; DateTime expirationDate = today.AddDays(Constant.days); Application.Current.Properties["time_stamp"] = expirationDate; accessToken = e.Account.Properties["access_token"]; refreshToken = e.Account.Properties["access_token"]; UpdateTokensPost updateTokens = new UpdateTokensPost(); updateTokens.access_token = accessToken; updateTokens.refresh_token = refreshToken; updateTokens.uid = (string)Application.Current.Properties["uid"]; updateTokens.social_timestamp = expirationDate.ToString("yyyy-MM-dd HH:mm:ss"); var updatePostSerilizedObject = JsonConvert.SerializeObject(updateTokens); var updatePostContent = new StringContent(updatePostSerilizedObject, Encoding.UTF8, "application/json"); var client = new HttpClient(); var RDSrespose = await client.PostAsync(Constant.UpdateTokensUrl, updatePostContent); if (RDSrespose.IsSuccessStatusCode) { FacebookUserProfileAsync(accessToken); } else { System.Diagnostics.Debug.WriteLine("Unable to update google tokens"); } } } }
public async void AppleUserProfileAsync(string appleId, string appleToken, string appleUserEmail, string userName) { System.Diagnostics.Debug.WriteLine("LINE 95"); var client = new HttpClient(); var socialLogInPost = new SocialLogInPost(); socialLogInPost.email = appleUserEmail; socialLogInPost.password = ""; socialLogInPost.social_id = appleId; socialLogInPost.signup_platform = "APPLE"; var socialLogInPostSerialized = JsonConvert.SerializeObject(socialLogInPost); System.Diagnostics.Debug.WriteLine(socialLogInPostSerialized); var postContent = new StringContent(socialLogInPostSerialized, Encoding.UTF8, "application/json"); var RDSResponse = await client.PostAsync(Constant.LogInUrl, postContent); var responseContent = await RDSResponse.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(responseContent); if (RDSResponse.IsSuccessStatusCode) { if (responseContent != null) { if (responseContent.Contains(Constant.EmailNotFound)) { var signUp = await Application.Current.MainPage.DisplayAlert("Message", "It looks like you don't have a MTYD account. Please sign up!", "OK", "Cancel"); if (signUp) { // HERE YOU NEED TO SUBSTITUTE MY SOCIAL SIGN UP PAGE WITH MTYD SOCIAL SIGN UP // NOTE THAT THIS SOCIAL SIGN UP PAGE NEEDS A CONSTRUCTOR LIKE THE FOLLOWING ONE // SocialSignUp(string socialId, string firstName, string lastName, string emailAddress, string accessToken, string refreshToken, string platform) Application.Current.MainPage = new CarlosSocialSignUp(appleId, userName, "", appleUserEmail, appleToken, appleToken, "APPLE"); } } if (responseContent.Contains(Constant.AutheticatedSuccesful)) { var data = JsonConvert.DeserializeObject <SuccessfulSocialLogIn>(responseContent); Application.Current.Properties["user_id"] = data.result[0].customer_uid; UpdateTokensPost updateTokesPost = new UpdateTokensPost(); updateTokesPost.uid = data.result[0].customer_uid; updateTokesPost.mobile_access_token = appleToken; updateTokesPost.mobile_refresh_token = appleToken; var updateTokesPostSerializedObject = JsonConvert.SerializeObject(updateTokesPost); var updateTokesContent = new StringContent(updateTokesPostSerializedObject, Encoding.UTF8, "application/json"); var updateTokesResponse = await client.PostAsync(Constant.UpdateTokensUrl, updateTokesContent); var updateTokenResponseContent = await updateTokesResponse.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(updateTokenResponseContent); if (updateTokesResponse.IsSuccessStatusCode) { DateTime today = DateTime.Now; DateTime expDate = today.AddDays(Constant.days); Application.Current.Properties["time_stamp"] = expDate; Application.Current.Properties["platform"] = "APPLE"; // Application.Current.MainPage = new SubscriptionPage(); Application.Current.MainPage = new NavigationPage(new SubscriptionPage()); // THIS IS HOW YOU CAN ACCESS YOUR USER ID FROM THE APP // string userID = (string)Application.Current.Properties["user_id"]; } else { await Application.Current.MainPage.DisplayAlert("Oops", "We are facing some problems with our internal system. We weren't able to update your credentials", "OK"); } } if (responseContent.Contains(Constant.ErrorPlatform)) { var RDSCode = JsonConvert.DeserializeObject <RDSLogInMessage>(responseContent); await Application.Current.MainPage.DisplayAlert("Message", RDSCode.message, "OK"); } if (responseContent.Contains(Constant.ErrorUserDirectLogIn)) { await Application.Current.MainPage.DisplayAlert("Oops!", "You have an existing MTYD account. Please use direct login", "OK"); } } } }
public async void AppleUserProfileAsync(string appleId, string appleToken, string appleUserEmail, string userName) { System.Diagnostics.Debug.WriteLine("LINE 95"); var client = new HttpClient(); var socialLogInPost = new SocialLogInPost(); socialLogInPost.email = appleUserEmail; socialLogInPost.password = ""; socialLogInPost.social_id = appleId; socialLogInPost.signup_platform = "APPLE"; var socialLogInPostSerialized = JsonConvert.SerializeObject(socialLogInPost); System.Diagnostics.Debug.WriteLine(socialLogInPostSerialized); var postContent = new StringContent(socialLogInPostSerialized, Encoding.UTF8, "application/json"); var RDSResponse = await client.PostAsync(Constant.LogInUrl, postContent); var responseContent = await RDSResponse.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(responseContent); if (RDSResponse.IsSuccessStatusCode) { if (responseContent != null) { var data5 = JsonConvert.DeserializeObject <SuccessfulSocialLogIn>(responseContent); if (data5.code.ToString() == Constant.EmailNotFound) { var signUp = await Application.Current.MainPage.DisplayAlert("Message", "It looks like you don't have a MTYD account. Please sign up!", "OK", "Cancel"); if (signUp) { // HERE YOU NEED TO SUBSTITUTE MY SOCIAL SIGN UP PAGE WITH MTYD SOCIAL SIGN UP // NOTE THAT THIS SOCIAL SIGN UP PAGE NEEDS A CONSTRUCTOR LIKE THE FOLLOWING ONE // SocialSignUp(string socialId, string firstName, string lastName, string emailAddress, string accessToken, string refreshToken, string platform) Preferences.Set("canChooseSelect", false); Application.Current.MainPage = new CarlosSocialSignUp(appleId, userName, "", appleUserEmail, appleToken, appleToken, "APPLE"); } } else if (data5.code.ToString() == Constant.AutheticatedSuccesful) { var data = JsonConvert.DeserializeObject <SuccessfulSocialLogIn>(responseContent); Application.Current.Properties["user_id"] = data.result[0].customer_uid; UpdateTokensPost updateTokesPost = new UpdateTokensPost(); updateTokesPost.uid = data.result[0].customer_uid; updateTokesPost.mobile_access_token = appleToken; updateTokesPost.mobile_refresh_token = appleToken; var updateTokesPostSerializedObject = JsonConvert.SerializeObject(updateTokesPost); Console.WriteLine("updateTokesPostSerializedObject: " + updateTokesPostSerializedObject.ToString()); var updateTokesContent = new StringContent(updateTokesPostSerializedObject, Encoding.UTF8, "application/json"); Console.WriteLine("updateTokesContent: " + updateTokesContent.ToString()); var updateTokesResponse = await client.PostAsync(Constant.UpdateTokensUrl, updateTokesContent); Console.WriteLine("updateTokesResponse: " + updateTokesResponse.ToString()); var updateTokenResponseContent = await updateTokesResponse.Content.ReadAsStringAsync(); Console.WriteLine("updateTokenResponseContent: " + updateTokenResponseContent.ToString()); System.Diagnostics.Debug.WriteLine(updateTokenResponseContent); if (updateTokesResponse.IsSuccessStatusCode) { DateTime today = DateTime.Now; DateTime expDate = today.AddDays(Constant.days); Application.Current.Properties["time_stamp"] = expDate; Application.Current.Properties["platform"] = "APPLE"; var request = new HttpRequestMessage(); Console.WriteLine("user_id: " + (string)Application.Current.Properties["user_id"]); string url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/customer_lplp?customer_uid=" + (string)Application.Current.Properties["user_id"]; //string url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/meals_selected?customer_uid=" + (string)Application.Current.Properties["user_id"]; //string url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/meals_selected?customer_uid=" + "100-000256"; Console.WriteLine("url: " + url); request.RequestUri = new Uri(url); //request.RequestUri = new Uri("https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/get_delivery_info/400-000453"); request.Method = HttpMethod.Get; var client2 = new HttpClient(); HttpResponseMessage response = await client2.SendAsync(request); if (response.StatusCode == System.Net.HttpStatusCode.OK) { HttpContent content = response.Content; Console.WriteLine("content: " + content); var userString = await content.ReadAsStringAsync(); Console.WriteLine(userString); //writing guid to db if (Preferences.Get("setGuid" + (string)Application.Current.Properties["user_id"], false) == false) { if (Device.RuntimePlatform == Device.iOS) { deviceId = Preferences.Get("guid", null); if (deviceId != null) { Debug.WriteLine("This is the iOS GUID from Log in: " + deviceId); } } else { deviceId = Preferences.Get("guid", null); if (deviceId != null) { Debug.WriteLine("This is the Android GUID from Log in " + deviceId); } } if (deviceId != null) { GuidPost notificationPost = new GuidPost(); notificationPost.uid = (string)Application.Current.Properties["user_id"]; notificationPost.guid = deviceId.Substring(5); Application.Current.Properties["guid"] = deviceId.Substring(5); notificationPost.notification = "TRUE"; var notificationSerializedObject = JsonConvert.SerializeObject(notificationPost); Debug.WriteLine("Notification JSON Object to send: " + notificationSerializedObject); var notificationContent = new StringContent(notificationSerializedObject, Encoding.UTF8, "application/json"); var clientResponse = await client.PostAsync(Constant.GuidUrl, notificationContent); Debug.WriteLine("Status code: " + clientResponse.IsSuccessStatusCode); if (clientResponse.IsSuccessStatusCode) { System.Diagnostics.Debug.WriteLine("We have post the guid to the database"); Preferences.Set("setGuid" + (string)Application.Current.Properties["user_id"], true); } else { Debug.WriteLine("Something went wrong. We are not able to send you notification at this moment"); } } } //written if (userString.ToString()[0] != '{') { url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/Profile/" + (string)Application.Current.Properties["user_id"]; var request3 = new HttpRequestMessage(); request3.RequestUri = new Uri(url); request3.Method = HttpMethod.Get; HttpResponseMessage response2 = await client.SendAsync(request3); content = response2.Content; Console.WriteLine("content: " + content); userString = await content.ReadAsStringAsync(); JObject info_obj3 = JObject.Parse(userString); this.NewMainPage.Clear(); Preferences.Set("user_latitude", (info_obj3["result"])[0]["customer_lat"].ToString()); Debug.WriteLine("user latitude" + Preferences.Get("user_latitude", "")); Preferences.Set("user_longitude", (info_obj3["result"])[0]["customer_long"].ToString()); Debug.WriteLine("user longitude" + Preferences.Get("user_longitude", "")); Preferences.Set("profilePicLink", ""); Console.WriteLine("go to SubscriptionPage"); Preferences.Set("canChooseSelect", false); Application.Current.MainPage = new NavigationPage(new SubscriptionPage((info_obj3["result"])[0]["customer_first_name"].ToString(), (info_obj3["result"])[0]["customer_last_name"].ToString(), (info_obj3["result"])[0]["customer_email"].ToString())); return; } JObject info_obj2 = JObject.Parse(userString); this.NewLogin.Clear(); //ArrayList item_price = new ArrayList(); //ArrayList num_items = new ArrayList(); //ArrayList payment_frequency = new ArrayList(); //ArrayList groupArray = new ArrayList(); //int counter = 0; //while (((info_obj2["result"])[0]).ToString() != "{}") //{ // Console.WriteLine("worked" + counter); // counter++; //} Console.WriteLine("string: " + (info_obj2["result"]).ToString()); //check if the user hasn't entered any info before, if so put in the placeholders if ((info_obj2["result"]).ToString() == "[]" || (info_obj2["result"]).ToString() == "204" || (info_obj2["result"]).ToString().Contains("ACTIVE") == false) { url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/Profile/" + (string)Application.Current.Properties["user_id"]; var request3 = new HttpRequestMessage(); request3.RequestUri = new Uri(url); request3.Method = HttpMethod.Get; response = await client.SendAsync(request3); content = response.Content; Console.WriteLine("content: " + content); userString = await content.ReadAsStringAsync(); JObject info_obj3 = JObject.Parse(userString); this.NewMainPage.Clear(); Preferences.Set("user_latitude", (info_obj3["result"])[0]["customer_lat"].ToString()); Debug.WriteLine("user latitude" + Preferences.Get("user_latitude", "")); Preferences.Set("user_longitude", (info_obj3["result"])[0]["customer_long"].ToString()); Debug.WriteLine("user longitude" + Preferences.Get("user_longitude", "")); Preferences.Set("profilePicLink", ""); Console.WriteLine("go to SubscriptionPage"); Preferences.Set("canChooseSelect", false); Application.Current.MainPage = new NavigationPage(new SubscriptionPage((info_obj2["result"])[0]["customer_first_name"].ToString(), (info_obj2["result"])[0]["customer_last_name"].ToString(), (info_obj2["result"])[0]["customer_email"].ToString())); } else { url = "https://ht56vci4v9.execute-api.us-west-1.amazonaws.com/dev/api/v2/Profile/" + (string)Application.Current.Properties["user_id"]; var request3 = new HttpRequestMessage(); request3.RequestUri = new Uri(url); request3.Method = HttpMethod.Get; response = await client.SendAsync(request3); content = response.Content; Console.WriteLine("content: " + content); userString = await content.ReadAsStringAsync(); JObject info_obj3 = JObject.Parse(userString); this.NewMainPage.Clear(); Preferences.Set("user_latitude", (info_obj3["result"])[0]["customer_lat"].ToString()); Debug.WriteLine("user latitude" + Preferences.Get("user_latitude", "")); Preferences.Set("user_longitude", (info_obj3["result"])[0]["customer_long"].ToString()); Debug.WriteLine("user longitude" + Preferences.Get("user_longitude", "")); Preferences.Set("profilePicLink", ""); Preferences.Set("canChooseSelect", true); Zones[] zones = new Zones[] { }; Application.Current.MainPage = new NavigationPage(new Select(zones, (info_obj2["result"])[0]["customer_first_name"].ToString(), (info_obj2["result"])[0]["customer_last_name"].ToString(), (info_obj2["result"])[0]["customer_email"].ToString())); } } // Application.Current.MainPage = new SubscriptionPage(); //Application.Current.MainPage = new NavigationPage(new SubscriptionPage()); // THIS IS HOW YOU CAN ACCESS YOUR USER ID FROM THE APP // string userID = (string)Application.Current.Properties["user_id"]; } else { await Application.Current.MainPage.DisplayAlert("Oops", "We are facing some problems with our internal system. We weren't able to update your credentials", "OK"); } } else if (data5.code.ToString() == Constant.ErrorPlatform) { var RDSCode = JsonConvert.DeserializeObject <RDSLogInMessage>(responseContent); await Application.Current.MainPage.DisplayAlert("Message", RDSCode.message, "OK"); } else if (data5.code.ToString() == Constant.ErrorUserDirectLogIn) { await Application.Current.MainPage.DisplayAlert("Oops!", "You have an existing MTYD account. Please use direct login", "OK"); } } } }
public async void FacebookUserProfileAsync(string accessToken) { var client = new HttpClient(); var socialLogInPost = new SocialLogInPost(); // Actual call to Facebooks end point now that we have the token (appending accessToken to URL in constants file) var facebookResponse = client.GetStringAsync(Constant.FacebookUserInfoUrl + accessToken); // makes the call to Facebook and returns True/False var userData = facebookResponse.Result; // returns Facebook email and social ID System.Diagnostics.Debug.WriteLine(facebookResponse); System.Diagnostics.Debug.WriteLine(userData); // Deserializes JSON object from info provided by Facebook FacebookResponse facebookData = JsonConvert.DeserializeObject <FacebookResponse>(userData); socialLogInPost.email = facebookData.email; socialLogInPost.password = ""; socialLogInPost.social_id = facebookData.id; socialLogInPost.signup_platform = "FACEBOOK"; // Create JSON object for Login Endpoint var socialLogInPostSerialized = JsonConvert.SerializeObject(socialLogInPost); var postContent = new StringContent(socialLogInPostSerialized, Encoding.UTF8, "application/json"); System.Diagnostics.Debug.WriteLine(socialLogInPostSerialized); // Call to RDS database with endpoint and JSON data var RDSResponse = await client.PostAsync(Constant.LogInUrl, postContent); // True or False if Parva's endpoint ran preperly. var responseContent = await RDSResponse.Content.ReadAsStringAsync(); // Contains Parva's code containing all the user data including userid System.Diagnostics.Debug.WriteLine(RDSResponse.IsSuccessStatusCode); // Response code is Yes/True if successful from httpclient system.net package System.Diagnostics.Debug.WriteLine(responseContent); // Response JSON that RDS returns if (RDSResponse.IsSuccessStatusCode) { if (responseContent != null) { // Do I don't have the email in RDS if (responseContent.Contains(Constant.EmailNotFound)) { var signUp = await DisplayAlert("Message", "It looks like you don't have a MTYD account. Please sign up!", "OK", "Cancel"); if (signUp) { // HERE YOU NEED TO SUBSTITUTE MY SOCIAL SIGN UP PAGE WITH MTYD SOCIAL SIGN UP // NOTE THAT THIS SOCIAL SIGN UP PAGE NEEDS A CONSTRUCTOR LIKE THE FOLLOWING ONE // SocialSignUp(string socialId, string firstName, string lastName, string emailAddress, string accessToken, string refreshToken, string platform) Application.Current.MainPage = new CarlosSocialSignUp(facebookData.id, facebookData.name, "", facebookData.email, accessToken, accessToken, "FACEBOOK"); // need to write new statment here ... } } // if Response content contains 200 if (responseContent.Contains(Constant.AutheticatedSuccesful)) { var data = JsonConvert.DeserializeObject <SuccessfulSocialLogIn>(responseContent); Application.Current.Properties["user_id"] = data.result[0].customer_uid; // converts RDS data into appication data. UpdateTokensPost updateTokensPost = new UpdateTokensPost(); updateTokensPost.uid = data.result[0].customer_uid; updateTokensPost.mobile_access_token = accessToken; updateTokensPost.mobile_refresh_token = accessToken; // only get access token from Facebook so we store the data again var updateTokensPostSerializedObject = JsonConvert.SerializeObject(updateTokensPost); var updateTokensContent = new StringContent(updateTokensPostSerializedObject, Encoding.UTF8, "application/json"); var updateTokensResponse = await client.PostAsync(Constant.UpdateTokensUrl, updateTokensContent); // This calls the database and returns True or False var updateTokenResponseContent = await updateTokensResponse.Content.ReadAsStringAsync(); System.Diagnostics.Debug.WriteLine(updateTokenResponseContent); if (updateTokensResponse.IsSuccessStatusCode) { DateTime today = DateTime.Now; DateTime expDate = today.AddDays(Constant.days); // Internal assignment - not from the database Application.Current.Properties["time_stamp"] = expDate; Application.Current.Properties["platform"] = "FACEBOOK"; // Application.Current.MainPage = new SubscriptionPage(); Application.Current.MainPage = new NavigationPage(new SubscriptionPage()); // THIS IS HOW YOU CAN ACCESS YOUR USER ID FROM THE APP //string userID = (string)Application.Current.Properties["user_id"]; //printing id for testing //System.Diagnostics.Debug.WriteLine("user ID after success: " + userID); } else { await DisplayAlert("Oops", "We are facing some problems with our internal system. We weren't able to update your credentials", "OK"); } } // Wrong Platform message if (responseContent.Contains(Constant.ErrorPlatform)) { var RDSCode = JsonConvert.DeserializeObject <RDSLogInMessage>(responseContent); await DisplayAlert("Message", RDSCode.message, "OK"); } // Wrong LOGIN method message if (responseContent.Contains(Constant.ErrorUserDirectLogIn)) { await DisplayAlert("Oops!", "You have an existing MTYD account. Please use direct login", "OK"); } } } }