I want to use same OAuth Code and Token for Both sheet and google drive api without redirecting to page 2 times for sheet and drive.
Following is the code for generating the access code and token using oauth 2
string SCOPE = "https://spreadsheets.google.com/feeds https://docs.google.com/feeds";
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.ClientId = CLIENT_ID;
parameters.ClientSecret = CLIENT_SECRET;
parameters.RedirectUri = REDIRECT_URI;
parameters.Scope = SCOPE;
string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters);
OAuthUtil.GetAccessToken(parameters);
string accessToken = parameters.AccessToken;
As in asp.net mvc its been generated through redirection for google sheet API.
I want to use google drive API for this same token also.
How i can create credential object for google Drive API in order to work with that. Following CODE OPENS ANOTHER WINDOW AND SEND CODE TO THAT WINDOW.
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
{
ClientId = clientId,
ClientSecret = clientSecret
}, scopes, "skhan", CancellationToken.None, new FileDataStore("Drive.Auth.Store")).Result;