Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Twilio/Http/BearerToken/ApiTokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function fetchToken(?Client $client = null): string {

try {
return $tokenList->create(
"client_credentials",
$this->options
)->accessToken;
}
Expand Down
1 change: 1 addition & 0 deletions src/Twilio/Http/BearerToken/OrgsTokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function fetchToken(?Client $client = null): string {

try {
return $tokenList->create(
"client_credentials",
$this->options
)->accessToken;
}
Expand Down
18 changes: 12 additions & 6 deletions src/Twilio/Rest/Oauth/V2/TokenList.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ public function __construct(
/**
* Helper function for Create
*
* @param string $grantType Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.

* @param array|Options $options Optional Arguments
* @return Response Created Response
* @throws TwilioException When an HTTP error occurs.
*/
private function _create(array $options = []): Response
private function _create(string $grantType, array $options = []): Response
{

$options = new Values($options);
Expand All @@ -62,7 +64,7 @@ private function _create(array $options = []): Response

$data = Values::of([
'grant_type' =>
$options['grantType'],
$grantType,
'client_id' =>
$options['clientId'],
'client_secret' =>
Expand All @@ -88,13 +90,15 @@ private function _create(array $options = []): Response
/**
* Create the TokenInstance
*
* @param string $grantType Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.

* @param array|Options $options Optional Arguments
* @return TokenInstance Created TokenInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function create(array $options = []): TokenInstance
public function create(string $grantType, array $options = []): TokenInstance
{
$response = $this->_create($options);
$response = $this->_create( $grantType, $options);
return new TokenInstance(
$this->version,
$response->getContent()
Expand All @@ -105,13 +109,15 @@ public function create(array $options = []): TokenInstance
/**
* Create the TokenInstance with Metadata
*
* @param string $grantType Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.

* @param array|Options $options Optional Arguments
* @return ResourceMetadata The Created Resource with Metadata
* @throws TwilioException When an HTTP error occurs.
*/
public function createWithMetadata(array $options = []): ResourceMetadata
public function createWithMetadata(string $grantType, array $options = []): ResourceMetadata
{
$response = $this->_create($options);
$response = $this->_create( $grantType, $options);
$resource = new TokenInstance(
$this->version,
$response->getContent()
Expand Down
18 changes: 0 additions & 18 deletions src/Twilio/Rest/Oauth/V2/TokenOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ abstract class TokenOptions
{
/**
* @param string $accountSid Optional Account SID to perform on behalf of requests.
* @param string $grantType Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.
* @param string $clientId A 34 character string that uniquely identifies this OAuth App.
* @param string $clientSecret The credential for confidential OAuth App.
* @param string $code JWT token related to the authorization code grant type.
Expand All @@ -36,7 +35,6 @@ abstract class TokenOptions
public static function create(

string $accountSid = Values::NONE,
string $grantType = Values::NONE,
string $clientId = Values::NONE,
string $clientSecret = Values::NONE,
string $code = Values::NONE,
Expand All @@ -50,7 +48,6 @@ public static function create(
{
return new CreateTokenOptions(
$accountSid,
$grantType,
$clientId,
$clientSecret,
$code,
Expand All @@ -68,7 +65,6 @@ class CreateTokenOptions extends Options
{
/**
* @param string $accountSid Optional Account SID to perform on behalf of requests.
* @param string $grantType Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.
* @param string $clientId A 34 character string that uniquely identifies this OAuth App.
* @param string $clientSecret The credential for confidential OAuth App.
* @param string $code JWT token related to the authorization code grant type.
Expand All @@ -81,7 +77,6 @@ class CreateTokenOptions extends Options
public function __construct(

string $accountSid = Values::NONE,
string $grantType = Values::NONE,
string $clientId = Values::NONE,
string $clientSecret = Values::NONE,
string $code = Values::NONE,
Expand All @@ -93,7 +88,6 @@ public function __construct(

) {
$this->options['accountSid'] = $accountSid;
$this->options['grantType'] = $grantType;
$this->options['clientId'] = $clientId;
$this->options['clientSecret'] = $clientSecret;
$this->options['code'] = $code;
Expand All @@ -116,18 +110,6 @@ public function setAccountSid(string $accountSid): self
return $this;
}

/**
* Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.
*
* @param string $grantType Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token.
* @return $this Fluent Builder
*/
public function setGrantType(string $grantType): self
{
$this->options['grantType'] = $grantType;
return $this;
}

/**
* A 34 character string that uniquely identifies this OAuth App.
*
Expand Down