public static async Task<ConnectionResult> ConnectToGoogleDrive(Controller controller, CancellationToken token)
        {
            string userId = controller.User.Identity.GetUserId();

            GoogleDriveService service = null;
            if (ServiceCache.TryGetValue(userId, out service))
                return new ConnectionResult(service, null);

            var result = await new AuthorizationCodeMvcApp(controller, new AppFlowMetadata()).AuthorizeAsync(token);

            if (result.Credential == null)
            {
                return new ConnectionResult(null, result.RedirectUri);
            }

            var Service = new DriveService(new BaseClientService.Initializer
            {
                HttpClientInitializer = result.Credential,
                ApplicationName = GoogleDriveSettings.APP_NAME
            });

            service = new GoogleDriveService(new DriveDataService(Service));

            ServiceCache[userId] = service;

            return new ConnectionResult(service, null);
        }
 public ConnectionResult(GoogleDriveService driveService, string redirect)
 {
     DriveService = driveService;
     Redirect = redirect;
 }