I
I
Ivan Balan2015-02-11 15:48:12
Google
Ivan Balan, 2015-02-11 15:48:12

How to store user credential using Google API .NET library?

I am using Google .NET OAuth2 library for user authorization. In addition, I need access to user data (for example, to calendars).
In Google examples, there is this piece of code:

var result = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata()).
            AuthorizeAsync(cancellationToken);

It sends the user to the Google authorization form if the user is not logged in, or returns an object that stores the so-called credentials. I use this piece in the Login controller, but I also need these credentials in other parts of the site to interact with user data.
var service = new CalendarService(new BaseClientService.Initializer
            {
                HttpClientInitializer = result.<b>Credential</b>,
                ApplicationName = "ASP.NET MVC Sample"
            });
           var items = service.CalendarList.List().Execute().Items;

This is how I can get a list of the user's calendars. How and where to store these very credentials, because this is not a simple character token, but an object that stores a lot of data.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Pukhov, 2015-02-12
@Neuroware

an object can be stored within the same class, but if you need to drag it between different parts, you can serialize it and store it wherever you like, even in cookies

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question