I use DelphiMVCFrameWork 3.2.1 for building the RESTful server for my mobile app.
For getting data I always use the basic auth. and I send the username and password everytime (for example):
procedure TDM.getGroupsFromServer;
var
Http: TIdHTTP;
ReqStr:string;
begin
try
Http := TIdHTTP.Create(nil);
Http.ReadTimeout := 10000;
Http.Request.ContentType := 'application/json';
Http.Request.CharSet := 'utf-8';
HTTP.Request.Accept:= '*/*';
Http.Request.BasicAuthentication:= true;//<---------
Http.Request.Username := DM.username;//<---------
Http.Request.Password := DM.password;//<---------
ReqStr:=Http.Get('http://'+SERVER_IP+':8080/api/groups');
groupsJSON:=ReqStr;
dsGroups.LoadFromJSONArrayString(ReqStr);
dsGroups.First;
finally
Http.Free;
end;
end;
Is there any login method and after that I do my requests and finally I call logout to terminate the connection?
- User login: by sending username & password
- User do CRUD operations (without sending user & pwd every call)
- User logout / connection timeout is occurred
Thanks in advance