You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Great package first of all. I have recently started to implement in my laravel package.
In this particular project, I'm trying to integrate external APIs (Machine to Machine) with OAuth2 authentication.
This service requires username: xxx and password: xxx along with client_id: xxx and 'client_secret: xxx**passed in the request body** when requesting anaccess_token`.
I'm not sure where to pass these additional variables within the connector class.
So far, I have done the following:
class ServiceConnector extends Connector
{
use ClientCredentialsGrant;
public function __construct(public array $connectionData)
{
}
/**
* The Base URL of the API.
*/
public function resolveBaseUrl(): string
{
return $this->connectionData['base_url'];
}
/**
* The OAuth2 configuration
*/
protected function defaultOauthConfig(): OAuthConfig
{
return OAuthConfig::make()
->setClientId($this->connectionData['client_id'])
->setClientSecret($this->connectionData['client_secret'])
->setRedirectUri($this->connectionData['base_url'])
->setDefaultScopes($this->connectionData['scopes'])
->setTokenEndpoint($this->connectionData['token_url'])
->setRequestModifier(function (Request $request) {
if ($request instanceof GetClientCredentialsTokenRequest) {
$request->body()->set([
'username' => $this->connectionData['username'],
'password' => $this->connectionData['password'],
'grant_type' => 'password',
]);
}
});
}
}
It seems like the variables passed via the setRequestModifier() method are not correctly going with the request as form body.
Am I missing something somewhere or this type of authentication has a different approach?
Any help is appreciated.
The text was updated successfully, but these errors were encountered:
Hi there,
Great package first of all. I have recently started to implement in my laravel package.
In this particular project, I'm trying to integrate external APIs (Machine to Machine) with OAuth2 authentication.
This service requires
username: xxx
andpassword: xxx
along withclient_id: xxx
and 'client_secret: xxx**passed in the request body** when requesting an
access_token`.I'm not sure where to pass these additional variables within the connector class.
So far, I have done the following:
It seems like the variables passed via the
setRequestModifier()
method are not correctly going with the request as form body.Am I missing something somewhere or this type of authentication has a different approach?
Any help is appreciated.
The text was updated successfully, but these errors were encountered: