private static async Task <string> SignInWithCustomTokenAsync(string customToken) { var rb = new Google.Apis.Requests.RequestBuilder() { Method = Google.Apis.Http.HttpConsts.Post, BaseUri = new Uri(VerifyCustomTokenUrl), }; rb.AddParameter(RequestParameterType.Query, "key", IntegrationTestUtils.GetApiKey()); var request = rb.CreateRequest(); var jsonSerializer = Google.Apis.Json.NewtonsoftJsonSerializer.Instance; var payload = jsonSerializer.Serialize(new SignInRequest { CustomToken = customToken, ReturnSecureToken = true, }); request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var parsed = jsonSerializer.Deserialize <SignInResponse>(json); return(parsed.IdToken); } }
private static async Task <string> ResetPasswordAsync(ResetPasswordRequest data) { var rb = new Google.Apis.Requests.RequestBuilder() { Method = Google.Apis.Http.HttpConsts.Post, BaseUri = new Uri(ResetPasswordUrl), }; rb.AddParameter(RequestParameterType.Query, "key", IntegrationTestUtils.GetApiKey()); var jsonSerializer = Google.Apis.Json.NewtonsoftJsonSerializer.Instance; var payload = jsonSerializer.Serialize(data); var request = rb.CreateRequest(); request.Content = new StringContent(payload, Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var parsed = jsonSerializer.Deserialize <Dictionary <string, object> >(json); return((string)parsed["email"]); } }