I let Google drive users log in and make use of their google drive data. However, only the first user need to authenticate and the following users get access to the first users data! What is wrong in this code?
public static DriveService GetService()
{
//get Credentials from client_secret.json file
UserCredential credential;
var path = HttpContext.Current.Server.MapPath(@"~/client_secret.json");
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
// The file token.json stores the user's access and refresh tokens, and is created
// automatically when the authorization flow completes for the first time.
string credPath = HttpContext.Current.Server.MapPath(@"~/token.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
//create Drive API service.
DriveService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "GoogleDriveRestAPI-v3",
});
return service;
}