From 26b01c7fffa619fa508057656bd90a30f39c1bcc Mon Sep 17 00:00:00 2001
From: Vincent Petry <pvince81@owncloud.com>
Date: Fri, 6 Nov 2015 12:35:28 +0100
Subject: [PATCH] Force approval in GDrive oauth to get refresh_token

Forcing the approval of app permissions makes sure that the GDrive API
will always return a refresh_token.

In the case of apps that were already authorized for the current user/domain,
the API doesn't return the refresh_token which causes expiration issues.
---
 apps/files_external/ajax/oauth2.php | 1 +
 1 file changed, 1 insertion(+)

diff --git a/apps/files_external/ajax/oauth2.php b/apps/files_external/ajax/oauth2.php
index e3e32c4b91..fbe60e16e2 100644
--- a/apps/files_external/ajax/oauth2.php
+++ b/apps/files_external/ajax/oauth2.php
@@ -41,6 +41,7 @@ if (isset($_POST['client_id']) && isset($_POST['client_secret']) && isset($_POST
 	$client->setClientSecret((string)$_POST['client_secret']);
 	$client->setRedirectUri((string)$_POST['redirect']);
 	$client->setScopes(array('https://www.googleapis.com/auth/drive'));
+	$client->setApprovalPrompt('force');
 	$client->setAccessType('offline');
 	if (isset($_POST['step'])) {
 		$step = $_POST['step'];
-- 
GitLab