Skip to content

Commit

Permalink
Merge pull request #6 from MeroFuruya/5-http-client-default-request-h…
Browse files Browse the repository at this point in the history
…eaders

fix #5
  • Loading branch information
MeroFuruya authored Apr 11, 2023
2 parents 643b5ab + 6b67aa7 commit 7c7ffe3
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions MicrosoftApiAuthenticator.pas
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,12 @@ constructor TMsDelegatedAuthenticator.Create(ClientInfo: TMsClientInfo;
begin
inherited Create;
self.FAuthenticatorType := TAthenticatorType.ATDelegated;

// setup HTTP Client
self.FHttpClient := THTTPClient.Create;
self.FHttpClient.Accept := 'application/json';
self.FHttpClient.ContentType := 'application/x-www-form-urlencoded';
self.FHttpClient.AcceptCharSet := TEncoding.UTF8.EncodingName;
//self.FHttpClient.Accept := 'application/json';
//self.FHttpClient.ContentType := 'application/x-www-form-urlencoded';
//self.FHttpClient.AcceptCharSet := TEncoding.UTF8.EncodingName;

// set Variables
self.FClientInfo := ClientInfo;
Expand Down Expand Up @@ -421,6 +422,9 @@ function TMsDelegatedAuthenticator.FDoRefreshToken: boolean;
+ '&redirect_uri=' + self.FClientInfo.RedirectUri.GetRedirectUri
+ '&grant_type=refresh_token');
ARequest.SourceStream := ARequestData;
// add Headers
ARequest.AddHeader('Content-Type', 'application/x-www-form-urlencoded');
ARequest.AddHeader('Accept', 'application/json');
// Execute Request
AResponse := self.FHttpClient.Execute(ARequest);
// Free Request Data Stream
Expand Down Expand Up @@ -541,6 +545,9 @@ function TMsDelegatedAuthenticator.FDoUserAuth: boolean;
+ '&redirect_uri=' + self.FClientInfo.RedirectUri.GetRedirectUri
+ '&grant_type=authorization_code');
ARequest.SourceStream := ARequestData;
// add Headers
ARequest.AddHeader('Content-Type', 'application/x-www-form-urlencoded');
ARequest.AddHeader('Accept', 'application/json');
// Execute Request
AResponse := self.FHttpClient.Execute(ARequest);
// Free Request Data Stream
Expand Down Expand Up @@ -795,9 +802,9 @@ constructor TMsDeamonAuthenticator.Create(ClientInfo: TMsClientInfo;
self.FAuthenticatorType := TAthenticatorType.ATDeamon;
// setup HTTP Client
self.FHttpClient := THTTPClient.Create;
self.FHttpClient.Accept := 'application/json';
self.FHttpClient.ContentType := 'application/x-www-form-urlencoded';
self.FHttpClient.AcceptCharSet := TEncoding.UTF8.EncodingName;
//self.FHttpClient.Accept := 'application/json';
//self.FHttpClient.ContentType := 'application/x-www-form-urlencoded';
//self.FHttpClient.AcceptCharSet := TEncoding.UTF8.EncodingName;

// set Variables
self.FClientInfo := ClientInfo;
Expand Down Expand Up @@ -898,6 +905,9 @@ function TMsDeamonAuthenticator.FDoGetNewToken: boolean;
+ '&client_secret=' + self.FClientInfo.ClientSecret
+ '&grant_type=client_credentials');
ARequest.SourceStream := ARequestData;
// add Headers
ARequest.AddHeader('Content-Type', 'application/x-www-form-urlencoded');
ARequest.AddHeader('Accept', 'application/json');
// Execute Request
AResponse := self.FHttpClient.Execute(ARequest);
// Free Request Data Stream
Expand Down

0 comments on commit 7c7ffe3

Please sign in to comment.