TAdvLiveCalendar authorize

How do i avoid having to authrorize on every connect. I am testing the LiveCalendarDemo, I do have the key and secret key. The ini file is correctly created, but the program ask for authorization on every connect?

Hi,


I have not been able to reproduce this issue.
Are you using the "Remove access" button or calling AdvLiveCalendar1.ClearTokens?
This will erase the access token and cause a request for authorization on the next connect.

I have the same problem. debugged the source (cloudlive.pas) and found out that there is no  "refresh_token" in the answer from the server (login.live.com). 

In procedure TCloudLive.NavigateComplete2()

Token_Refresh := GetJSONProp(jo,'refresh_token');   

is empty because there is no refresh_token in resdat (=server answer). So in live.ini  "REFRESH_TOKEN=". On every new start and connect DoAuth is called again.

Any idea how to get a valid refresh_token? Google Calendar works fine.

Hi,


I've re-tested this and while using our test-account a refresh token is provided in the server answer data. 
I'm not sure why there is no refresh token in your case, I'll have to investigate if this requires a specific configuration setting.

An extra scope (wl.offline_acess) is required to retrieve a refresh token for Live Calendar, .
You can add the extra scope in your application code before authentication is started.

Example:
  AdvLiveCalendar1.Scopes.Add('wl.offline_access');

thx. extra scope added and now I get  a refresh_token in  AdvLiveCalendar1.RefreshAccess. but next line  AdvLiveCalendar1.TestTokens returns false because there is no "name"  in server answer. So still DoAuth is called on every new start/connect.

procedure TForm1.ButtonConnectClick(Sender: TObject);
begin
AdvLiveCalendar1.Scopes.Add('wl.offline_access'); 
AdvLiveCalendar1.App.Key := LiveAppKey;
AdvLiveCalendar1.App.Secret := LiveAppSecret;
AdvLiveCalendar1.Logging := true;
if not AdvLiveCalendar1.TestTokens then
   AdvLiveCalendar1.RefreshAccess; //True, got refresh_token 

//

//TestTokens in next line returns false. in TestTokens in Result := (GetJSONProp(o,'id') <> '') and (GetJSONProp(o,'name') <> ''); there is a prop 'id' <> '' but prop 'name' = ''. 

//
if not AdvLiveCalendar1.TestTokens then
   AdvLiveCalendar1.DoAuth
else
   Init;
end;


The server should return the "name" field if the scopes contain "wl.basic".
This scope is added by default.


Can you please let me know which fields are returned in the server answer when TestTokens is called so I can further investigate this?

It was my fault. In my Microsoft Live account data was no name specified, just my e-mail. After adding my name to my account data everything works fine now. thx for your help.