Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
KGOrders
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cam Hayes
KGOrders
Commits
4b122972
Commit
4b122972
authored
2 weeks ago
by
Cam Hayes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated qb qpi stil doesnt work
parent
55ffb9ae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
33 deletions
+27
-33
qbAPI.pas
kgOrdersServer/Source/qbAPI.pas
+26
-32
kgOrdersServer.ini
kgOrdersServer/kgOrdersServer.ini
+1
-1
No files found.
kgOrdersServer/Source/qbAPI.pas
View file @
4b122972
...
...
@@ -10,7 +10,7 @@ uses
System
.
Generics
.
Collections
,
AdvEdit
,
vcl
.
wwdblook
,
vcl
.
wwdbdatetimepicker
,
System
.
Hash
,
Api
.
Database
,
Vcl
.
ExtCtrls
,
WEBLib
.
Forms
,
WEBLib
.
Controls
,
WEBLib
.
StdCtrls
,
WEBLib
.
ExtCtrls
,
WEBLib
.
REST
,
WEBLib
.
WebTools
,
System
.
Net
.
HttpClient
,
System
.
Net
.
URLClient
,
System
.
Net
.
HttpClientComponent
;
System
.
Net
.
URLClient
,
System
.
Net
.
HttpClientComponent
,
System
.
netencoding
;
type
...
...
@@ -25,6 +25,7 @@ type
{ Public declarations }
procedure
getCompanyInfo
();
procedure
getAccessToken
();
//function refreshAccessToken(): boolean;
end
;
var
...
...
@@ -40,6 +41,8 @@ begin
//getCompanyInfo();
end
;
procedure
TfQB
.
getAccessToken
();
var
restClient
:
TRESTClient
;
...
...
@@ -63,54 +66,45 @@ begin
client
:=
'ABgO14uvjh8XqLud7spQ8lkb98AUpcdA7HbyMJfCAtl65sQ5yy'
;
secret
:=
'bQ06TRemHeAGFzVHRaTUvUoBU9jpU9itK6MOMgqN'
;
companyID
:=
'9341454272655710'
;
RefreshToken
:=
'AB11751305638q5pAyQI2MPvhkIGjH1ur3PRsas2zSKGGcC4vs'
;
EncodedAuth
:=
'QUJnTzE0dXZqaDhYcUx1ZDdzcFE4bGtiOThBVXBjZEE3SGJ5TUpmQ0F0bDY1c1E1eXk6YlEwNlRSZW1IZUFHRnpWSFJhVFV2VW9CVTlqcFU5aXRLNk1PTWdxTg=='
;
RefreshToken
:=
'AB11751554594LX59YtRB69e6vWUjg56d9zCWjOOUisSTd6VfC'
;
//EncodedAuth := 'QUJnTzE0dXZqaDhYcUx1ZDdzcFE4bGtiOThBVXBjZEE3SGJ5TUpmQ0F0bDY1c1E1eXk6YlEwNlRSZW1IZUFHRnpWSFJhVFV2VW9CVTlqcFU5aXRLNk1PTWdxTg==';
EncodedAuth
:=
TNetEncoding
.
Base64
.
Encode
(
client
+
':'
+
secret
);
// Prepare the REST client and request
restClient
:=
TRESTClient
.
Create
(
'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'
);
restClient
:=
TRESTClient
.
Create
(
nil
);
restRequest
:=
TRESTRequest
.
Create
(
nil
);
restRequest
.
Client
:=
restClient
;
restResponse
:=
TRESTResponse
.
Create
(
nil
);
restRequest
.
Response
:=
restResponse
;
rest
Request
.
Method
:=
rmPOST
;
rest
Client
.
BaseURL
:=
'https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'
;
// Set the Accept header (application/json)
restRequest
.
Params
.
Clear
;
restRequest
.
Method
:=
rmPOST
;
// Add Content-Type and Accept headers
restRequest
.
AddParameter
(
'Content-Type'
,
'application/x-www-form-urlencoded'
,
pkHTTPHEADER
);
restRequest
.
AddParameter
(
'Accept'
,
'application/json'
,
pkHTTPHEADER
);
restRequest
.
AddParameter
(
'Authorization'
,
'Basic '
+
EncodedAuth
,
pkHTTPHEADER
);
// Construct body content like -d "grant_type=refresh_token&refresh_token=AB11751305638q5pAyQI2MPvhkIGjH1ur3PRsas2zSKGGcC4vs"
body
:=
'grant_type=refresh_token&refresh_token='
+
RefreshToken
;
restClient
.
Accept
:=
'application/json'
;
restClient
.
ContentType
:=
'application/x-www-form-urlencoded'
;
//restClient.RaiseExceptionOn500 := false;
// Add body parameters as form-urlencoded data
restRequest
.
AddBody
(
body
,
TRESTContentType
.
ctAPPLICATION_X_WWW_FORM_URLENCODED
);
restRequest
.
Params
.
Clear
;
Memo1
.
Lines
.
add
(
restRequest
.
ContentType
);
param
:=
restRequest
.
Params
.
AddItem
;
param
.
Name
:=
'Authorization'
;
param
.
Kind
:=
pkHTTPHEADER
;
param
.
Options
:=
param
.
Options
+
[
TRESTRequestParameterOption
.
poDoNotEncode
];
param
.
Value
:=
'Basic '
+
EncodedAuth
;
//restRequest.Params.AddHeader('Authorization', 'Basic ' + EncodedAuth);
// Log the request URL and method
Memo1
.
Lines
.
Add
(
'Request URL: '
+
restRequest
.
Client
.
BaseURL
+
restRequest
.
Resource
);
restRequest
.
Params
.
AddItem
(
'grant_type'
,
'refresh_token'
);
restRequest
.
Params
.
AddItem
(
'refresh_token'
,
RefreshToken
);
// Log headers
Memo1
.
Lines
.
Add
(
'Headers:'
);
for
item
in
restRequest
.
Params
do
begin
Memo1
.
Lines
.
Add
(
item
.
Value
);
end
;
Memo1
.
Lines
.
Add
(
item
.
Name
+
':'
+
item
.
Value
);
restRequest
.
Method
:=
rmPOST
;
// Log body (raw form data)
Memo1
.
Lines
.
Add
(
'Body:'
);
Memo1
.
Lines
.
Add
(
body
);
Memo1
.
Lines
.
Add
(
'--- Request Logged ---'
);
restRequest
.
Execute
;
// Log response for debugging
Memo1
.
Lines
.
Add
(
'Status Code: '
+
IntToStr
(
restResponse
.
StatusCode
));
Memo1
.
Lines
.
Add
(
'Response: '
+
restResponse
.
Content
);
Memo1
.
Lines
.
Add
(
'Response Headers: '
+
restResponse
.
Headers
.
Text
);
//Memo1.Lines.Add(restRequest.Response.Content);
restClient
.
Free
;
restRequest
.
Free
;
...
...
This diff is collapsed.
Click to expand it.
kgOrdersServer/kgOrdersServer.ini
View file @
4b122972
[Settings]
MemoLogLevel
=
4
FileLogLevel
=
5
LogFileNum
=
3
54
LogFileNum
=
3
72
webClientVersion
=
1.0.0
[Database]
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment