Sunday, April 9, 2017

ASP.NET Identity - Invalid token error

I was generating a code for a user to reset her password. However, this error came up when trying to reset the password. I had 2 problems:

1) The token was being generated in a computer that was not where the token was actually used. I read in SO that the token is tied to a key in the web.config, so either the web.config -keep in mind that ASP.NET has a hierarchy of web.config files, so there's more than 1- needs to match or you need to generate and use the token in the same server.
2) The token contained the plus sign (+). When using it, the server encoded it as a space, so you need to do string.Replace(" ", "+")