OneDrive and ExternalBrowser under iOS

Hello,


I believe there is an issue under iOS with ExternalBrowser for OneDrive.
I checked also your CloudStorageDemo.

Try to connect and you will see the login page.
After input the username and the pasword only a blank page will be shown.
Then go back to the app and you will see that no connection was done.

I restarted the app and tried the login again.
But now I only get the blank page without any comments/outputs.
The only thing I can do is to close the window...

Okay, it seems that I have to extend the permissions for the app in the new Azure portal. In the past I used the old portal. That's why I used your manual: https://www.tmssoftware.com/site/cloudkey.asp#microsoft

You write: 
In the Redirect URI section:
Select "Web"
Enter a valid redirect URL.
Exampe: "http://localhost:8000"
Do I have to change the callback URL in the OneDrive componenent also? Currently the callback url is https://login.live.com/oauth20_desktop.srf

My problem is I tried it also with http://localhost:8000 but then I will get an error message at browser login:

"invalid_request: The provided value for the input parameter 'redrirect_uri' is not valid. The expected value is a URI which matches a rediredt URI registered for this client application."

The application ID and the secret key are correct defined in the application.

Have you tried using the callback url "https://login.live.com/oauth20_desktop.srf" both in the Azure portal and the component?

Yes, I tried also the callback URL https://login.live.com/oauth20_desktop.srf and Port 80. It was my standard setting. But there I will get the error: "Could not bind socket. Address and port are already in use."
Then I changed the port to 8080 and after login I will get a blank page.

Btw. I use the OneDrive account also in my VCL program with the same credentials and settings and there it works. I can login and download/upload data.

There was an issue with assigning the Callback URL in the component.
This has now been fixed and the update will be available with the next release.

Nice to hear, thank you for the great support.

Happy to help.

Please note that when ExternalBrowser is set to true, it is recommended to use a local callback URL like: "http://localhost:8000"
Make sure that an identical URL is assigned to both the App.CallBackURL and in the Azure console, then authentication should work as expected after the update.

One question: When do you plan to release the update?

An update release for TMS FMX Cloud Pack is planned for next week.
If you urgently require this fix you can request an incremental source update by sending an email to mailto:help@tmssoftware.com

Hello,


thanks for the incremental source update. Now it works and I can access the OneDrive Cloud.

But after some times if I want to load files from there I have to reauthentificate my access. The app switches to the browser and address localhost:8000 and shows me the message "Application succesfully authorized. You can close this browser window".
Is there a AccessTokenLifeTime like in GoogleDrive?

Hi,


Unfortunately there is no equivalent to AccessTokenLifeTime in OneDrive. This is a limitation of the OneDrive API which we have no control over.

However there should be a refresh token included with the access token after authentication which you can use in combination with a RefreshAccess call to avoid displaying the browser window. If you're using a Connect call to start authentication this is built-in.
Hi,

I use your Connect call to make the authentication! In FMX.TMSCloudCustomWinLive.pas I can see the comment:

// v1.4.1.3 : Fixed : Possible issue with RefreshAccess call

Maybe this refresh doesn't work with the new ExternalBrowser, because of the "localhost:8000"?

Thank you for notifying us, there was indeed an issue related to the RefreshAccess.
The issue has now been fixed and the update will be available with the next release.

Hello,

sorry, to bother you again.

Now I have the same problem again with a new app.

My other apps were defined at the old Microsoft site https://apps.dev.microsoft.com/#/appList. And this apps work with "old" ClientID and SecretKey and the ExternalBrowser option.

The new app I set up at the Azure portal like the description in your manual https://www.tmssoftware.com/site/cloudkey.asp#microsoft

In my code I define
OneDrive.App.Key := Application (Client) ID;
OneDrive.App.Secret := Client Secret;

The redirect URI is localhost://8000 which is also defined as CallBackup Url in the component.

If I start the login all seems to be okay. From OneDrive I get the the information "Application successfully authorized. You can close the browser window."
But after closing the window nothing happens. In debug mode the app doesn't call any of the events in TTMSFMXCloudOneDrive component.

What could be wrong with the new defined apps?

Best regards
Heiko

Hi,


I'm not sure what could be causing this issue.

Does the issue happen on Windows as well?
Have you tried using the log file to see if any error messages are displayed?
Logging can be enabled by setting Logging to True and LogLevel to llDetail.
The log file is generated automatically in the machine's Documents folder.

If the problem persists you can also try using Fiddler (free download) to view more details for the executed HTTP requests and possible error messages.

Hi Bart,


i checked the windows version and there is the same problem.
In the log file I can see the following messages:

<h2>Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon.</p>

And:
20200422T111725:HTTPS POST RESULT:{"error":"invalid_request","error_description":"Public clients can't send a client secret.","correlation_id":"xxxx-yyyyy-zzzz"}

It seems Microsofts OneDrive has a problem since a few days. That would mean, that all users can't login via an app with the new client secret? There are no messages on the Azure protal about that problem. 

The only solution will be, that I use the applictaion ID of one of my old apps to use it in my new app, since the problem will be solved...
Update:

Now I used the old application ID and I get the same html output "<h2>Our services aren't available right now</h2>".
But the HTTPS POST RES is 200 instead of 400. Can you say why?

New application ID
20200422T111723:HTTPS GET: https://api.onedrive.com/v1.0/drive/items/root?access_token=
20200422T111723:HTTPS GET RESULT:<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='content-type'/><style type='text/css'>body {font-family:Arial; margin-left:40px; }img  { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p  { font-size: 13px; color: #000000; margin: 7px 0px 0px0px}#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>OneDrive</title></head><body><div id='content'><div id='message'><h2>Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon.</p></div><div id='errorref'><span>Ref A: 724F1CE606344A41B6EA31455BCFAEC3 Ref B: FRAEDGE0811 Ref C: 2020-04-22T09:17:24Z</span></div></div></body></html>
20200422T111724:HTTPS POST: login.live.com/oauth20_token.srf
20200422T111725:HTTPS POST RES:400
20200422T111725:HTTPS POST RESULT:{"error":"invalid_request","error_description":"Public clients can't send a client secret.","correlation_id":"xxx-xxx-xxx-xxx-xxx"}

Old application ID
20200422T112617:HTTPS GET: https://api.onedrive.com/v1.0/drive/items/root?access_token=
20200422T112617:HTTPS GET RESULT:<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='content-type'/><style type='text/css'>body {font-family:Arial; margin-left:40px; }img  { border:0 none; }#content { margin-left: auto; margin-right: auto }#message h2 { font-size: 20px; font-weight: normal; color: #000000; margin: 34px 0px 0px 0px }#message p  { font-size: 13px; color: #000000; margin: 7px 0px 0px0px}#errorref { font-size: 11px; color: #737373; margin-top: 41px }</style><title>OneDrive</title></head><body><div id='content'><div id='message'><h2>Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon.</p></div><div id='errorref'><span>Ref A: 8E435AFF2F1F4E64B30D66E014A68115 Ref B: FRAEDGE0911 Ref C: 2020-04-22T09:26:18Z</span></div></div></body></html>
20200422T112618:HTTPS POST: login.live.com/oauth20_token.srf
20200422T112619:HTTPS POST RES:200
20200422T112619:HTTPS POST RESULT:{"token_type":"bearer","expires_in":3600,"scope":"wl.signin wl.basic wl.offline_access wl.skydrive wl.skydrive_update","access_token":"aLongToken"}

Hi,

I retested the OneDrive authentication and API access with a new application ID and haven't been able to reproduce an issue.

Can you please make sure your new application is configured correctly?
Which option did you select for "Supported account types"?
Have you tried selecting a different option?


This is my selection:


and this is the information in Supported Account types (in german)