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.
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.
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
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.
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?
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.
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).
Have you tried setting the Target Platform to 64-bit Windows in the Delphi IDE?
This issue has been fixed.
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.
Updates on the documentation available at http://www.tmssoftware.com/site/cloudkey.asp#microsoft are coming as soon as possible.
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.
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.
Thanks for the update!
I am getting the same 401 error. The log shows:
20191204T115831: Executing request [TEST TOKENS] with url: [https://graph.microsoft.com/v1.0/me/drive]
20191204T115831: Response code from request [TEST TOKENS] is 401
I set the correct client id and secret, and use as redirect url http://localhost:8000
I got it already working by enabling the Standardclienttype.
Thanks for notifying the issue was resolved.
Yes, issue solved, but the online help to setup the client id need to be updated. The part with the standard client type setting is missing.
We'll look into updating the online documentation where needed.