0

I'm trying to find a solution for getting a new Refresh Token after the existing one has expired.
The Google APIs Client Library for .NET Developer's Guide provides this hint:

Both UserCredential and ServiceAccountCredential implement IConfigurableHttpClientInitializer so you can register each of these as:

  • An unsuccessful response handler, so it will refresh the token if it receives an HTTP 401 status code.
  • An interceptor, to intercept the Authorization header on every request.

Did anybody figure out how to register UserCredential as an unsuccessful response handler and make it handle the 401s automatically?

Community
  • 1
  • 1
jansokoly
  • 1,994
  • 2
  • 18
  • 25

1 Answers1

0

By setting the HttpClientInitializer on the BaseServiceInitializer the library does all the magic for you (https://code.google.com/p/google-api-dotnet-client/source/browse/Drive.Sample/Program.cs?repo=samples#106) - it refreshes the token when it expires.

peleyal
  • 3,472
  • 1
  • 14
  • 25