I was struggling to find the correct way of implementing OAuth with Google API and finally managed to get it working by implementing a DataStore to manage the users access tokens.
However it has now stopped working, and by that I mean once the code has redirected me to Google and I've selected a profile and authorized the app to access the requested information my app throws a TokenResponseException
Server Error in '/' Application.
Error:"State is invalid", Description:"", Uri:""
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Google.Apis.Auth.OAuth2.Responses.TokenResponseException: Error:"State is invalid", Description:"", Uri:""
What I have noticed is that the FileDataStore
I passed to IAuthorizationCodeFlow
is no longer creating files in the specified directory. Where as before it was creating a file with a name similar to System.String-oauth_5f798cfd-0d9a-42ad-a05b-567fda21d916
which was just a text file with my url inside of it.
For clarity the url which throws this error is https://myurl.net/AuthCallback/IndexAsync?state=https://myurl.net/dashboard32977907&code=4/PAtdUBSV4noqSna3j5ELkan0eOel.wu5woMyVz9kWYKs_1NgQtmV75cIkiQI