Web forum is in read-only mode. Login as active registered customer for write access
  Forum Search   New Posts New Posts

OneDrive connection

 Post Reply Post Reply
Author
GoldWave Chris View Drop Down
New Member
New Member
Avatar

Joined: 26 Jun 2019
Posts: 12
Post Options Post Options   Quote GoldWave Chris Quote  Post ReplyReply Direct Link To This Post Topic: OneDrive connection
    Posted: 09 Jul 2019 at 5:40pm
Connections to Google Drive and Dropbox are working, but the OneDrive component fails to connect.  I have set the correct client ID, secret and URL.  Everything seems to work normally at first.  The app is successfully granted an authorization code (the message appears in the browser).  However the OnConnected event never occurs and the OnRequestTestTokensResult is not called with ATestTokensResult set to true.  OnRequestComplete occurs with ARequestResult.success set to false and a 400 error.
Back to Top
Bart Holvoet View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2052
Post Options Post Options   Quote Bart Holvoet Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jul 2019 at 10:33am
Hi,

I have not been able to reproduce this issue.
Does the issue also occur in the demo application included with TMS FNC Cloud Pack?

If the issue persists, can you please provide a LOG file so I can further investigate this?
To enable logging set Logging to True, the LOG file is automatically generated in the machine's Documents folder.
Back to Top
GoldWave Chris View Drop Down
New Member
New Member
Avatar

Joined: 26 Jun 2019
Posts: 12
Post Options Post Options   Quote GoldWave Chris Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jul 2019 at 3:23pm
The log only gives the following information:

20190710T104300: Executing request [GET USER INFO] with url: [https://graph.microsoft.com/v1.0/me/drive]
20190710T104301: Response code from request [GET USER INFO] is 401
20190710T104318: Executing request [RETRIEVE ACCESS TOKEN] with url: [https://login.microsoftonline.com/common/oauth2/v2.0/token]
20190710T104318: Response code from request [RETRIEVE ACCESS TOKEN] is 400

I am using the 64 bit version of TTMSFNCCloudMicrosoftOneDrive.

Back to Top
Bart Holvoet View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2052
Post Options Post Options   Quote Bart Holvoet Quote  Post ReplyReply Direct Link To This Post Posted: 10 Jul 2019 at 4:33pm
Can you please try using a tool like Fiddler (free download) to inspect the full HTTP requests that are executed?
If you can provide this data it will make it easier for us to determine what exactly is going wrong.

Can you also verify you followed the instructions indicated at https://www.tmssoftware.com/site/cloudkey.asp#microsoft correclty?
Back to Top
GoldWave Chris View Drop Down
New Member
New Member
Avatar

Joined: 26 Jun 2019
Posts: 12
Post Options Post Options   Quote GoldWave Chris Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 2019 at 10:13pm
The instructions on that page suggest setting the Return URI to "https://login.live.com/oauth20_desktop.srf" or to "https://www.microsoft,.com" (in the image).  Those do not work.  When using the first one, no "authorization successful" message appears in the web browser and OnConnect is not called.  The second one is obviously wrong.  Using "http://127.0.0.1:8000" seems to work, but OnConnect and OnAuthenticated are not called (despite seeing a successful message in the browser).

It appears the 64 bit debug versions of the libraries are not available and there is no information on how to build the debug versions with MSBuild (what special parameters are required to generate the .a file).  The following doesn't work (no .a file is created in the Debug folder):
  msbuild /p:platform=Win64 /p:config=Debug FMXTMSFNCCorePkgDXE12.dproj

Can you provide the msbuild parameters so I can debug through the code?

It seems that TTMSFNCCustomCloudMicrosoftOneDrive.TestTokens(...) is doing a 'GET USER INFO' request instead of a 'TEST TOKENS' request.
Back to Top
GoldWave Chris View Drop Down
New Member
New Member
Avatar

Joined: 26 Jun 2019
Posts: 12
Post Options Post Options   Quote GoldWave Chris Quote  Post ReplyReply Direct Link To This Post Posted: 12 Jul 2019 at 3:32pm
The problem seems to be that the request for an access tokens fails (AADSTS700016: Application with identifier... was not found in the directory...).  Microsoft seems to be deprecating the Application registration portal.  Unfortunately the OneDrive component isn't compatible with the new system.

Also there seems to be a problem with the flow of authorization.  Currently you have:
1. Get authentication code.
2. Show message in browser.
3. Request access token.

If #3 fails, the user is given the wrong impression that the app has access.  In fact the app does not have access and the OnConnect event never occurs.  Perhaps #3 should be processed before showing a message in the web browser.

Another issue is that there is no easy way to determine if the connection failed.  Using OnRequestComplete is difficult because it can occur more than once per connection (sometimes with a valid unsuccessful request when testing tokens).

Back to Top
Bart Holvoet View Drop Down
TMS Support
TMS Support
Avatar

Joined: 18 May 2010
Posts: 2052
Post Options Post Options   Quote Bart Holvoet Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jul 2019 at 12:40pm
Originally posted by GoldWave Chris

It appears the 64 bit debug versions of the libraries are not available and there is no information on how to build the debug versions with MSBuild (what special parameters are required to generate the .a file).  The following doesn't work (no .a file is created in the Debug folder):
  msbuild /p:platform=Win64 /p:config=Debug FMXTMSFNCCorePkgDXE12.dproj

Can you provide the msbuild parameters so I can debug through the code? 

Have you tried setting the Target Platform to 64-bit Windows in the Delphi IDE?

Originally posted by GoldWave Chris

It seems that TTMSFNCCustomCloudMicrosoftOneDrive.TestTokens(...) is doing a 'GET USER INFO' request instead of a 'TEST TOKENS' request.

This issue has been fixed.

Originally posted by GoldWave Chris

The problem seems to be that the request for an access tokens fails (AADSTS700016: Application with identifier... was not found in the directory...).  Microsoft seems to be deprecating the Application registration portal.  Unfortunately the OneDrive component isn't compatible with the new system.

The compatibility issue with the new console has been fixed.
Updates on the documentation available at http://www.tmssoftware.com/site/cloudkey.asp#microsoft are coming as soon as possible.

Originally posted by GoldWave Chris

Also there seems to be a problem with the flow of authorization.  Currently you have:
1. Get authentication code.
2. Show message in browser.
3. Request access token.

If #3 fails, the user is given the wrong impression that the app has access.  In fact the app does not have access and the OnConnect event never occurs.  Perhaps #3 should be processed before showing a message in the web browser.

This behaviour is by design. The message in the browser only indicates that an authentication token was received. At this time the request for retrieving the access token has not yet been processed.

Originally posted by GoldWave Chris

Another issue is that there is no easy way to determine if the connection failed.  Using OnRequestComplete is difficult because it can occur more than once per connection (sometimes with a valid unsuccessful request when testing tokens).

A new event OnAccessDenied has been introduced. This event is triggered when retrieving the access token fails. The ARequestResult.Resultstring contains the error message provided by the cloud service if avaialble.
 
These updates will be available with the TMS FNC Cloud Pack Beta planned for release later this week.
Back to Top
GoldWave Chris View Drop Down
New Member
New Member
Avatar

Joined: 26 Jun 2019
Posts: 12
Post Options Post Options   Quote GoldWave Chris Quote  Post ReplyReply Direct Link To This Post Posted: 16 Jul 2019 at 4:32pm
Thanks for the update!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down