forked from loafle/openapi-generator-original
add oauth support for php
This commit is contained in:
@@ -170,8 +170,8 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
if (isset($apiKey)) {
|
||||
{{#isKeyInHeader}}$headerParams['{{keyParamName}}'] = $apiKey;{{/isKeyInHeader}}{{#isKeyInQuery}}$queryParams['{{keyParamName}}'] = $apiKey;{{/isKeyInQuery}}
|
||||
}{{/isApiKey}}
|
||||
{{#isBasic}}$headerParams['Authorization'] = 'Basic '.base64_encode($this->apiClient->getConfig()->getUsername().":".$this->apiClient->getConfig()->getPassword());{{/isBasic}}
|
||||
{{#isOAuth}}//TODO support oauth{{/isOAuth}}
|
||||
{{#isBasic}}$headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername(). ":" .$this->apiClient->getConfig()->getPassword());{{/isBasic}}
|
||||
{{#isOAuth}}$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAuthToken();{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
// make the API Call
|
||||
try
|
||||
|
||||
@@ -63,6 +63,13 @@ class Configuration
|
||||
*/
|
||||
protected $apiKeyPrefixes = array();
|
||||
|
||||
/**
|
||||
* Token for OAuth
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $authToken = '';
|
||||
|
||||
/**
|
||||
* Username for HTTP basic authentication
|
||||
*
|
||||
@@ -195,6 +202,29 @@ class Configuration
|
||||
return isset($this->apiKeyPrefixes[$apiKeyIdentifier]) ? $this->apiKeyPrefixes[$apiKeyIdentifier] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the token for OAuth
|
||||
*
|
||||
* @param string $authToken Token for OAuth
|
||||
*
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setAuthToken($authToken)
|
||||
{
|
||||
$this->$authToken = $authToken;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the token for OAuth
|
||||
*
|
||||
* @return string Token for OAuth
|
||||
*/
|
||||
public function getAuthToken()
|
||||
{
|
||||
return $this->authToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username for HTTP basic authentication
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user