Skip to content

Commit 81fd3ad

Browse files
committed
client fix
1 parent 73b4583 commit 81fd3ad

File tree

3 files changed

+34
-37
lines changed

3 files changed

+34
-37
lines changed

Diff for: Samples/OpenMasterdata.dproj

+9-30
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
33
<ProjectGuid>{3972419D-CF6D-415D-BE30-6C8E7969A200}</ProjectGuid>
4-
<ProjectVersion>20.1</ProjectVersion>
4+
<ProjectVersion>20.2</ProjectVersion>
55
<FrameworkType>VCL</FrameworkType>
66
<Base>True</Base>
77
<Config Condition="'$(Config)'==''">Debug</Config>
88
<Platform Condition="'$(Platform)'==''">Win32</Platform>
99
<TargetedPlatforms>3</TargetedPlatforms>
1010
<AppType>Application</AppType>
1111
<MainSource>OpenMasterdata.dpr</MainSource>
12+
<ProjectName Condition="'$(ProjectName)'==''">OpenMasterdata</ProjectName>
1213
</PropertyGroup>
1314
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
1415
<Base>true</Base>
@@ -112,6 +113,7 @@ $(PostBuildEvent)]]></PostBuildEvent>
112113
<AppDPIAwarenessMode>PerMonitorV2</AppDPIAwarenessMode>
113114
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
114115
<VerInfo_Locale>1033</VerInfo_Locale>
116+
<DCC_DebugDCUs>true</DCC_DebugDCUs>
115117
</PropertyGroup>
116118
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
117119
<AppEnableRuntimeThemes>true</AppEnableRuntimeThemes>
@@ -161,22 +163,11 @@ $(PostBuildEvent)]]></PostBuildEvent>
161163
<Excluded_Packages>
162164
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k290.bpl">Microsoft Office 2000 Beispiele für gekapselte Komponenten für Automatisierungsserver</Excluded_Packages>
163165
<Excluded_Packages Name="$(BDSBIN)\dclofficexp290.bpl">Microsoft Office XP Beispiele für gekapselte Komponenten für Automation Server</Excluded_Packages>
164-
<Excluded_Packages Name="_C:\Program Files (x86)\madCollection\madExcept\BDS23\win32\madExceptWizard_.bpl">Datei _C:\Program Files (x86)\madCollection\madExcept\BDS23\win32\madExceptWizard_.bpl nicht gefunden</Excluded_Packages>
165-
<Excluded_Packages Name="_C:\Program Files (x86)\madCollection\madExcept\BDS23\win32\madExceptVcl_.bpl">Datei _C:\Program Files (x86)\madCollection\madExcept\BDS23\win32\madExceptVcl_.bpl nicht gefunden</Excluded_Packages>
166-
<Excluded_Packages Name="_C:\Program Files (x86)\madCollection\madExcept\BDS23\win32\madExcept_.bpl">Datei _C:\Program Files (x86)\madCollection\madExcept\BDS23\win32\madExcept_.bpl nicht gefunden</Excluded_Packages>
167-
<Excluded_Packages Name="_C:\Program Files (x86)\madCollection\madDisAsm\BDS23\win32\madDisAsm_.bpl">Datei _C:\Program Files (x86)\madCollection\madDisAsm\BDS23\win32\madDisAsm_.bpl nicht gefunden</Excluded_Packages>
168-
<Excluded_Packages Name="_C:\Program Files (x86)\madCollection\madBasic\BDS23\win32\madHelp_.bpl">Datei _C:\Program Files (x86)\madCollection\madBasic\BDS23\win32\madHelp_.bpl nicht gefunden</Excluded_Packages>
169-
<Excluded_Packages Name="_C:\Program Files (x86)\madCollection\madBasic\BDS23\win32\madBasic_.bpl">Datei _C:\Program Files (x86)\madCollection\madBasic\BDS23\win32\madBasic_.bpl nicht gefunden</Excluded_Packages>
170166
</Excluded_Packages>
171167
</Delphi.Personality>
172-
<Deployment Version="4">
168+
<Deployment Version="5">
169+
<DeployFile LocalName="Win32\Debug\OpenMasterdata.exe" Configuration="Debug" Class="ProjectOutput"/>
173170
<DeployFile LocalName="Win32\Debug\OpenMasterdata.exe" Configuration="Debug" Class="ProjectOutput"/>
174-
<DeployFile LocalName="Win32\Debug\OpenMasterdata.exe" Configuration="Debug" Class="ProjectOutput">
175-
<Platform Name="Win32">
176-
<RemoteName>OpenMasterdata.exe</RemoteName>
177-
<Overwrite>true</Overwrite>
178-
</Platform>
179-
</DeployFile>
180171
<DeployClass Name="AdditionalDebugSymbols">
181172
<Platform Name="iOSSimulator">
182173
<Operation>1</Operation>
@@ -189,16 +180,6 @@ $(PostBuildEvent)]]></PostBuildEvent>
189180
<Operation>0</Operation>
190181
</Platform>
191182
</DeployClass>
192-
<DeployClass Name="AndroidClasses">
193-
<Platform Name="Android">
194-
<RemoteDir>classes</RemoteDir>
195-
<Operation>64</Operation>
196-
</Platform>
197-
<Platform Name="Android64">
198-
<RemoteDir>classes</RemoteDir>
199-
<Operation>64</Operation>
200-
</Platform>
201-
</DeployClass>
202183
<DeployClass Name="AndroidFileProvider">
203184
<Platform Name="Android">
204185
<RemoteDir>res\xml</RemoteDir>
@@ -209,12 +190,6 @@ $(PostBuildEvent)]]></PostBuildEvent>
209190
<Operation>1</Operation>
210191
</Platform>
211192
</DeployClass>
212-
<DeployClass Name="AndroidGDBServer">
213-
<Platform Name="Android">
214-
<RemoteDir>library\lib\armeabi-v7a</RemoteDir>
215-
<Operation>1</Operation>
216-
</Platform>
217-
</DeployClass>
218193
<DeployClass Name="AndroidLibnativeArmeabiFile">
219194
<Platform Name="Android">
220195
<RemoteDir>library\lib\armeabi</RemoteDir>
@@ -837,6 +812,9 @@ $(PostBuildEvent)]]></PostBuildEvent>
837812
<Platform Name="Win64">
838813
<Operation>1</Operation>
839814
</Platform>
815+
<Platform Name="Win64x">
816+
<Operation>1</Operation>
817+
</Platform>
840818
</DeployClass>
841819
<DeployClass Name="ProjectiOSDeviceDebug">
842820
<Platform Name="iOSDevice32">
@@ -1130,6 +1108,7 @@ $(PostBuildEvent)]]></PostBuildEvent>
11301108
<ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
11311109
<ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
11321110
<ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
1111+
<ProjectRoot Platform="Win64x" Name="$(PROJECTNAME)"/>
11331112
</Deployment>
11341113
<Platforms>
11351114
<Platform value="Win32">True</Platform>

Diff for: Samples/OpenMasterdata.res

0 Bytes
Binary file not shown.

Diff for: intf.OpenMasterdata.pas

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
License OpenMasterdata-for-Delphi
33
44
Copyright (C) 2024 Landrix Software GmbH & Co. KG
@@ -78,6 +78,9 @@ TValidateCertificatHelper = class(TObject)
7878
FAccessTokenValidTo : TDateTime;
7979
//FCookie : String;
8080

81+
FOAuthUrl : String;
82+
FBySupplierPIDUrl : String;
83+
8184
FRESTClientOAuth: TRESTClient;
8285
FRESTClientBySupplierPID: TRESTClient;
8386

@@ -261,7 +264,10 @@ function TOpenMasterdataApiClient.Login: Boolean;
261264
RESTRequest.Name := 'RESTRequest';
262265
RESTRequest.AssignedValues := [TCustomRESTRequest.TAssignedValue.rvConnectTimeout, TCustomRESTRequest.TAssignedValue.rvReadTimeout];
263266
RESTRequest.Client := FRESTClientOAuth;
267+
RESTRequest.Resource := FOAuthUrl;
264268
RESTRequest.Method := rmPOST;
269+
RESTRequest.Accept := '*/*';
270+
265271
case FGrantType of
266272
omdgt_Password: RESTRequest.Params.AddItem('grant_type','password');
267273
omdgt_ClientCredentials: RESTRequest.Params.AddItem('grant_type','client_credentials');
@@ -270,7 +276,8 @@ function TOpenMasterdataApiClient.Login: Boolean;
270276
RESTRequest.Params.AddItem('client_secret',FClientSecret);
271277
if not FClientScope.IsEmpty then
272278
RESTRequest.Params.AddItem('scope',FClientScope);
273-
RESTRequest.Params.AddItem('client_id',FClientID);
279+
if FClientID <> '' then
280+
RESTRequest.Params.AddItem('client_id',FClientID);
274281

275282
if (FUsername <> '') and (FCustomerNumber <> '') then
276283
RESTRequest.Params.AddItem('username',FUsername+#9+FCustomerNumber)
@@ -287,7 +294,7 @@ function TOpenMasterdataApiClient.Login: Boolean;
287294

288295
if not RESTResponse.Status.SuccessOK_200 then
289296
begin
290-
FLastErrorMessage := RESTResponse.StatusText;
297+
FLastErrorMessage := RESTResponse.StatusText+' '+RESTResponse.Content;
291298
FLastErrorCode := RESTResponse.StatusCode;
292299
exit;
293300
end;
@@ -298,7 +305,7 @@ function TOpenMasterdataApiClient.Login: Boolean;
298305
FAccessTokenValidTo := now;
299306
try
300307
try
301-
itm.LoadFromJson(RESTResponse.Content);
308+
itm.LoadFromJson(FLastOAuthResponseContent);
302309

303310
if itm.access_token.IsEmpty then
304311
exit;
@@ -352,8 +359,10 @@ function TOpenMasterdataApiClient.RefreshLogin: Boolean;
352359
RESTRequest.Name := 'RESTRequest';
353360
RESTRequest.AssignedValues := [TCustomRESTRequest.TAssignedValue.rvConnectTimeout, TCustomRESTRequest.TAssignedValue.rvReadTimeout];
354361
RESTRequest.Client := FRESTClientOAuth;
362+
RESTRequest.Resource := FOAuthUrl;
355363
RESTRequest.Params.AddItem('grant_type','refresh_token');
356-
RESTRequest.Params.AddItem('client_id',FClientID);
364+
if FClientID <> '' then
365+
RESTRequest.Params.AddItem('client_id',FClientID);
357366
RESTRequest.Params.AddItem('refresh_token',FRefreshToken);
358367
RESTRequest.Response := RESTResponse;
359368

@@ -431,6 +440,7 @@ function TOpenMasterdataApiClient.GetBySupplierPid(_SupplierPid: String;
431440
RESTRequest.Name := 'RESTRequest';
432441
RESTRequest.AssignedValues := [TCustomRESTRequest.TAssignedValue.rvConnectTimeout, TCustomRESTRequest.TAssignedValue.rvReadTimeout];
433442
RESTRequest.Client := FRESTClientBySupplierPID;
443+
RESTRequest.Resource := FBySupplierPIDUrl;
434444
RESTRequest.AddAuthParameter('Authorization','Bearer ' + FAccessToken,TRESTRequestParameterKind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]);
435445
//if FCookie <> '' then
436446
// RESTRequest.AddAuthParameter('Cookie',FCookie,TRESTRequestParameterKind.pkCOOKIE, [TRESTRequestParameterOption.poDoNotEncode]);
@@ -549,17 +559,25 @@ class function TOpenMasterdataApiClient.GetGrantTypeFromString(
549559

550560
procedure TOpenMasterdataApiClient.SetBySupplierPIDURL(
551561
const _URL : String);
562+
var
563+
lUrl : TURI;
552564
begin
553-
FRESTClientBySupplierPID.BaseURL := _URL;
565+
lUrl := TURI.Create(_URL);
566+
FBySupplierPIDUrl := lUrl.Path;
567+
FRESTClientBySupplierPID.BaseURL := lUrl.Scheme+'://'+lUrl.Host+':'+lUrl.Port.ToString;
554568
FRESTClientBySupplierPID.Accept := 'application/json';
555569
FRESTClientBySupplierPID.AcceptCharSet := 'UTF-8';
556570
FRESTClientBySupplierPID.ContentType := 'application/json';
557571
FRESTClientBySupplierPID.HandleRedirects := true;
558572
end;
559573

560574
procedure TOpenMasterdataApiClient.SetOAuthURL(const _URL : String);
575+
var
576+
lUrl : TURI;
561577
begin
562-
FRESTClientOAuth.BaseURL := _URL;
578+
lUrl := TURI.Create(_URL);
579+
FOAuthUrl := lUrl.Path;
580+
FRESTClientOAuth.BaseURL := lUrl.Scheme+'://'+lUrl.Host+':'+lUrl.Port.ToString;
563581
end;
564582

565583
{ TOpenMasterdataApiClient.TValidateCertificatHelper }

0 commit comments

Comments
 (0)