I am using yii2-authclient OAuth1 to query Atlassian Jira API. Everything is setup properly and is working on the Jira side. I can use Atlassian PHP example to query API calls using Guzzle OauthPlugin successfully. When I use yii2-authclient OAuth1 I get the following error when I try to make a simple API call.
[color="#FF0000"][i]Request failed with code: 401, message: {"errorMessages":["You do not have the permission to see the specified issue.","Login Required"],"errors":{}}
[/i][/color]
I have compared the http request logs from my working example (outside of yii2) with the http request logs from yii2-authclient and yii2-httpclient, the log information appear to be correct. I have also compared my working example code with yii2-authclient code, and although the code is slightly different, they both accomplish the same http post/get results.
Is there something within yii2 framework that is causing a different outcome that would make the API calls fail?
Config
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
// all Auth clients will use this configuration for HTTP client:
'httpClient' => [
'transport' => 'yii\httpclient\CurlTransport',
'requestConfig' => [
'format' => 'json'
]
]
'clients' => [
'myJiraInstance' => [
'class' => 'common\models\JiraOAuth',
'authUrl' => 'jira-instance-url.com' . '/plugins/servlet/oauth/authorize',
'requestTokenUrl' => 'jira-instance-url.com' . '/plugins/servlet/oauth/request-token',
'accessTokenUrl' => 'jira-instance-url.com' . '/plugins/servlet/oauth/access-token',
'apiBaseUrl' => 'jira-instance-url.com' . '/rest/api/2',
'requestTokenMethod' => 'POST',
'accessTokenMethod' => 'POST',
'name' => 'myJiraInstance',
'title' => 'My Jira Instance',
'consumerKey' => 'myJiraConsumerkey',
'consumerSecret' => '',
'signatureMethod' => [
'class' => 'yii\authclient\signature\RsaSha1',
'privateCertificateFile' => 'c:\path-to-my-jira\private-cert-file.pem',
]
]
]
],
Controller
public function actions()
{
return [
'auth' => [
'class' => 'yii\authclient\AuthAction',
'successCallback' => [$this, 'oAuthSuccess'],
],
];
}
public function oAuthSuccess($client)
{
// get user data from client
$userAttributes = $client->getUserAttributes();
}
public function actionIssue()
{
$oauthClient = Yii::$app->authClientCollection->getClient('myJiraInstance');
$response = $oauthClient->createApiRequest()
->setMethod('GET')
->setUrl('issue/ADCI-71')
->send();
return $this->render('issue', [
'response' => $response->content,
]);
}
View
<?php
echo print_r($response);
?>