Revert authentication
This commit is contained in:
Pedro Silva 2024-02-19 14:48:02 +00:00
parent 288abde752
commit e0dd215d92
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
7 changed files with 41 additions and 43 deletions

View file

@ -74,25 +74,18 @@ class UserIdToken {
$url = trailingslashit( $this->host ) . 'v1/oauth2/token?grant_type=client_credentials&response_type=id_token&intent=sdk_init';
if ( $target_customer_id ) {
// $url = add_query_arg(
// array(
// 'target_customer_id' => $target_customer_id,
// ),
// $url
// );
$url = add_query_arg(
array(
'target_customer_id' => $target_customer_id,
),
$url
);
}
// TODO fix this to use Bearer instead of Basic auth:
$settings = PPCP::container()->get( 'wcgateway.settings' );
$key = $settings->has( 'client_id' ) && $settings->get( 'client_id' ) ? $settings->get( 'client_id' ) : null;
$secret = $settings->has( 'client_secret' ) && $settings->get( 'client_secret' ) ? $settings->get( 'client_secret' ) : null;
$args = array(
'method' => 'POST',
'headers' => array(
// 'Authorization' => 'Bearer ' . $bearer->token(),
'Authorization' => 'Basic ' . base64_encode( "$key:$secret" ),
'Authorization' => 'Bearer ' . $bearer->token(),
'Content-Type' => 'application/x-www-form-urlencoded',
),
);