# Exception Thrown trying to GeneratePasswordResetToken

**URL:** <https://www.virtocommerce.org/t/exception-thrown-trying-to-generatepasswordresettoken/581>\
**Category:** dev\
**Tags:** storefront\
**Created:** [May 15, 2023, 12:03pm UTC](https://www.virtocommerce.org/t/exception-thrown-trying-to-generatepasswordresettoken/581 "2023-05-15T12:03:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sherif](https://yyz2.discourse-cdn.com/flex032/user_avatar/www.virtocommerce.org/sherif/32/249_2.png) [@sherif](https://www.virtocommerce.org/u/sherif)\
**Post date:** [May 15, 2023, 12:03pm UTC](https://www.virtocommerce.org/t/exception-thrown-trying-to-generatepasswordresettoken/581/1 "2023-05-15T12:03:19Z")

</div>

Hello,  
I get an exception in AutoRest client when trying to Generate Password Reset Token:

- VC Storefront at [6.16.0 · VirtoCommerce/vc-storefront@dcc5da5 · GitHub](https://github.com/VirtoCommerce/vc-storefront/commit/dcc5da51c0eb63ddb9db9219273056ec05722ac6)  
VC Platform 3.306.0

Fails in class VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi.Security  
Method ` public async Task<HttpOperationResponse<string>> GeneratePasswordResetTokenWithHttpMessagesAsync(string userId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))`

```auto
Newtonsoft.Json.JsonReaderException
  HResult=0x80131500
  Message=Unexpected character encountered while parsing value: C. Path '', line 1, position 1.
  Source=Newtonsoft.Json
  StackTrace:
   at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
   at Newtonsoft.Json.JsonTextReader.ReadAsString()
   at Newtonsoft.Json.JsonReader.ReadForType(JsonContract contract, Boolean hasConverter)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject[T](String json, JsonSerializerSettings settings)
   at VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi.Security.<GeneratePasswordResetTokenWithHttpMessagesAsync>d__43.MoveNext() in C:\sherian\Market\src\virto\vc-storefront\VirtoCommerce.Storefront\AutoRestClients\PlatformModuleApi.cs:line 13431

  This exception was originally thrown at this call stack:
    [External Code]
    VirtoCommerce.Storefront.AutoRestClients.PlatformModuleApi.Security.GeneratePasswordResetTokenWithHttpMessagesAsync(string, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>, System.Threading.CancellationToken) in PlatformModuleApi.cs

```

---

<div class="post-metadata">

**Author:** ![sherif](https://yyz2.discourse-cdn.com/flex032/user_avatar/www.virtocommerce.org/sherif/32/249_2.png) [@sherif](https://www.virtocommerce.org/u/sherif)\
**Post date:** [May 15, 2023, 12:28pm UTC](https://www.virtocommerce.org/t/exception-thrown-trying-to-generatepasswordresettoken/581/2 "2023-05-15T12:28:19Z")

</div>

I have bypassed this error by ignoring the attemp to serialse the returned token into a string: meaning;  
when the response status code returned from Platform API is status-code 200  
the response content is read as a string from the response stream on this line:

- `_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);`

I then avoid the attempt to desrialize this in the try/catch:

- `_result.Body = SafeJsonConvert.DeserializeObject<string>(_responseContent, Client.DeserializationSettings);`

and I instead set the value to the result body directly, as in:

- `_result.Body = _requestContent;`

This returns the result to the Controller, and I receive the email.

However, I am unsure how my UI should handle this? What is the expected workflow from here? A new Page providing new Password entry by the user?

Can you point to any theme that completes this process, that is not using GraphQL

---

<div class="post-metadata">

**Author:** ![OlegoO](https://yyz2.discourse-cdn.com/flex032/user_avatar/www.virtocommerce.org/olegoo/32/27_2.png) [@OlegoO](https://www.virtocommerce.org/u/OlegoO)\
**Post date:** [May 16, 2023, 1:29pm UTC](https://www.virtocommerce.org/t/exception-thrown-trying-to-generatepasswordresettoken/581/3 "2023-05-16T13:29:09Z")

</div>

@sherif Did you test API call in Swagger? Is it works on your environment?
