Using Delphi 10.4, Web Core...
I'm trying to access myCloudData without the user's first having to login.
In Connect to myCloudData without Login request Bruno indicated that:
You could as an alternative generate an access token once and always directly use the access token for accessing the service without going via OAUTH then anymore.
Which sounds like what I want.
I ran the "...web core demos Services\TMSWeb_myClouddata" project, and verified I could connect to a table in my account (this required an Auth login)
I then added a webedit and button - after succesfully connecting, I did:
WebEdit1.Text := WebmyCloudData1.AccessToken;
I then copied the access token to be used in the code.
I tried various versions of setting
WebmyCloudData1.AccessToken:= < long string >;
Unfortunately, the login screen always appears the first time run in a browser.
Looking at TRestClient.Connect, I see:
if FPersistTokens.Enabled then
begin
ReadTokens;
if AccessToken <> '' then
begin
TestTokens;
end
else
DoAuth;
end
else
DoAuth;
So, I cheerfully did this:
WebmyCloudData1.ClearTokens;
WebmyCloudData1.PersistTokens.Enabled:=True;
WebmyCloudData1.PersistTokens.Key:='myCloudData';
WebmyCloudData1.AccessToken:= < long string >;
WebmyCloudData1. (write tokens here)
WebmyCloudData1.connect;
Unfortunately, WriteTokens is protected in WEBLib.Rest.pas, so I can't "pre-save" the access token just before calling it up.
Am I missing the blindingly obvious here? Is there an easier way of setting up the access token such that I don't need to present a login form to the users?
TIA
Cheers,
EdB