0

I am trying to find out C# code which help me to access google analytic data using the access token. I have a web application where user can login using their google account, in background I am generating a oAuth2.0 access token and storing in my db, which will be used by my background job to access their analytic data.

I found many samples on the net but all samples are having code to authorization just before accessing the analytic api. but in my case I dont want to have authorization at the time of sending request to api as I have already generated the access token with appropriate scope for google analytic api.

Please help me to find out proper solution for this.

Please let me know if required any more information for my problem.

Vijay Sutaria
  • 132
  • 1
  • 11

1 Answers1

1

Storing the access token should NOT be enough. Access token is valid for only 60 minutes.

You need to store the refresh token, and that is exactly what the library does for you - https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth#user-credentials

UPDATE: Take a look in this thread: .NET Google api 1.7 beta authenticating with refresh token. It's exaplined how can you reuse the refresh token (in case you already stored it somewhere and you don't want your users to get the authorization page over and over again).

Community
  • 1
  • 1
peleyal
  • 3,472
  • 1
  • 14
  • 25