summaryrefslogtreecommitdiff
path: root/ucb/source
diff options
context:
space:
mode:
authorChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2020-12-08 11:53:12 +0100
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2020-12-14 12:22:18 +0100
commit9cfcf83f53e0ae897b30705f790c6ebe0b86932e (patch)
tree1f964a18a8c8ef0704e87d162f3852bc403f52ac /ucb/source
parente0a90aa3239621958bddbb30f98163e8c1ef857f (diff)
tdf#115643 make onedrive work again by switching to graph API
the live SDK method had been deprecated quite a while ago and has been turned off a while back. Notes: While you can access and save existing files using the remote files dialog, creating new files or using "save as" requires using the LibreOffice open/save dialogs. Authentication is clunky: username and password you're asked when creating a new connection is not used at all for connecting, so only fill out a username to label your onedrive entry. Actual authentication is done in browser - copy'n'paste the URL from the dialog into the browser, login and approve access for LibreOffice (approving access only necessary once), then you get redirected to localhost, ignore that there is nothing to display. The important part is the code from the URL-bar. Copy and paste that into the LibreOffice dialog and LO can request an authentication token for API access. Testing this feature requires compiling with corresponding api-keys specified in configure/having an app registered with microsoft. Change-Id: I2db11ac09f9fdc354a10d6c749b2bec84b5d34a9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107646 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'ucb/source')
-rw-r--r--ucb/source/ucp/cmis/auth_provider.cxx2
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx13
2 files changed, 13 insertions, 2 deletions
diff --git a/ucb/source/ucp/cmis/auth_provider.cxx b/ucb/source/ucp/cmis/auth_provider.cxx
index f9eb99db2553..dd7b4f9f1e3c 100644
--- a/ucb/source/ucp/cmis/auth_provider.cxx
+++ b/ucb/source/ucp/cmis/auth_provider.cxx
@@ -96,7 +96,7 @@ namespace cmis
"Open the following link in your browser and "
"paste the code from the URL you have been redirected to in the "
"box below. For example:\n"
- "https://login.live.com/oauth20_desktop.srf?code=YOUR_CODE&lc=1033",
+ "http://localhost/LibreOffice?code=YOUR_CODE",
url_oustr );
xIH->handle( xRequest.get() );
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index 14cdb1bbddc7..60bd54b722ec 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -346,11 +346,20 @@ namespace cmis
string rUsername = OUSTR_TO_STDSTR( m_aURL.getUsername( ) );
string rPassword = OUSTR_TO_STDSTR( m_aURL.getPassword( ) );
+ bool bSkipInitialPWAuth = false;
+ if ( m_aURL.getBindingUrl( ) == ONEDRIVE_BASE_URL ) {
+ // skip the initial username and pw-auth prompt, the only supported method is the
+ // auth-code-fallback one (login with your browser, copy code into the dialog)
+ // TODO: if LO were to listen on localhost for the request, it would be much nicer
+ // user experience
+ bSkipInitialPWAuth = true;
+ }
+
bool bIsDone = false;
while ( !bIsDone )
{
- if (aAuthProvider.authenticationQuery(rUsername, rPassword))
+ if (bSkipInitialPWAuth || aAuthProvider.authenticationQuery(rUsername, rPassword))
{
// Initiate a CMIS session and register it as we found nothing
libcmis::OAuth2DataPtr oauth2Data;
@@ -369,6 +378,8 @@ namespace cmis
ALFRESCO_CLOUD_CLIENT_ID, ALFRESCO_CLOUD_CLIENT_SECRET ) );
if ( m_aURL.getBindingUrl( ) == ONEDRIVE_BASE_URL )
{
+ // reset the skip, so user gets a chance to cancel
+ bSkipInitialPWAuth = false;
libcmis::SessionFactory::setOAuth2AuthCodeProvider(AuthProvider::onedriveAuthCodeFallback);
oauth2Data.reset( new libcmis::OAuth2Data(
ONEDRIVE_AUTH_URL, ONEDRIVE_TOKEN_URL,