|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Helper class for generating OAuth related credentials |
4 |
| - * |
5 |
| - * Copyright © Magento, Inc. All rights reserved. |
6 |
| - * See COPYING.txt for license details. |
| 3 | + * Copyright 2015 Adobe |
| 4 | + * All Rights Reserved. |
7 | 5 | */
|
8 | 6 | namespace Magento\TestFramework\Authentication;
|
9 | 7 |
|
10 | 8 | use Magento\Framework\Exception\IntegrationException;
|
11 | 9 | use Magento\Framework\Exception\LocalizedException;
|
12 | 10 | use Magento\Framework\Oauth\Exception;
|
13 |
| -use Magento\TestFramework\Authentication\Rest\OauthClient; |
14 | 11 | use Magento\TestFramework\Helper\Bootstrap;
|
15 |
| -use OAuth\Common\Consumer\Credentials; |
16 | 12 | use Laminas\Stdlib\Exception\LogicException;
|
17 | 13 | use Magento\Integration\Model\Integration;
|
| 14 | +use Magento\TestFramework\Authentication\Rest\OauthClient; |
18 | 15 |
|
19 | 16 | /**
|
20 | 17 | * Authentication Oauth helper
|
@@ -67,41 +64,6 @@ public static function getConsumerCredentials($date = null)
|
67 | 64 | ];
|
68 | 65 | }
|
69 | 66 |
|
70 |
| - /** |
71 |
| - * Create an access token to associated to a consumer to access APIs. No resources are available to this consumer. |
72 |
| - * |
73 |
| - * @return array comprising of token key and secret |
74 |
| - * <pre> |
75 |
| - * array ( |
76 |
| - * 'key' => 'ajdsjashgdkahsdlkjasldkjals', //token key |
77 |
| - * 'secret' => 'alsjdlaskjdlaksjdlasjkdlas', //token secret |
78 |
| - * 'oauth_client' => $oauthClient // OauthClient instance used to fetch the access token |
79 |
| - * ); |
80 |
| - * </pre> |
81 |
| - * @throws LocalizedException |
82 |
| - * @throws Exception |
83 |
| - * @throws \OAuth\Common\Http\Exception\TokenResponseException |
84 |
| - */ |
85 |
| - public static function getAccessToken() |
86 |
| - { |
87 |
| - $consumerCredentials = self::getConsumerCredentials(); |
88 |
| - $credentials = new Credentials($consumerCredentials['key'], $consumerCredentials['secret'], TESTS_BASE_URL); |
89 |
| - $oAuthClient = new OauthClient($credentials); |
90 |
| - $requestToken = $oAuthClient->requestRequestToken(); |
91 |
| - $accessToken = $oAuthClient->requestAccessToken( |
92 |
| - $requestToken->getRequestToken(), |
93 |
| - $consumerCredentials['verifier'], |
94 |
| - $requestToken->getRequestTokenSecret() |
95 |
| - ); |
96 |
| - |
97 |
| - /** TODO: Reconsider return format. It is not aligned with method name. */ |
98 |
| - return [ |
99 |
| - 'key' => $accessToken->getAccessToken(), |
100 |
| - 'secret' => $accessToken->getAccessTokenSecret(), |
101 |
| - 'oauth_client' => $oAuthClient |
102 |
| - ]; |
103 |
| - } |
104 |
| - |
105 | 67 | /**
|
106 | 68 | * Create an access token, tied to integration which has permissions to all API resources in the system.
|
107 | 69 | *
|
@@ -132,14 +94,13 @@ public static function getApiAccessCredentials($resources = null, ?Integration $
|
132 | 94 | throw new LogicException('Access token was not created.');
|
133 | 95 | }
|
134 | 96 | $consumer = $oauthService->loadConsumer($integration->getConsumerId());
|
135 |
| - $credentials = new Credentials($consumer->getKey(), $consumer->getSecret(), TESTS_BASE_URL); |
136 |
| - /** @var $oAuthClient OauthClient */ |
137 |
| - $oAuthClient = new OauthClient($credentials); |
| 97 | + $oauthClientObj = $objectManager->create(OauthClient::class); |
| 98 | + $oauthClient = $oauthClientObj->create($consumer->getKey(), $consumer->getSecret()); |
138 | 99 |
|
139 | 100 | self::$_apiCredentials = [
|
140 | 101 | 'key' => $accessToken->getToken(),
|
141 | 102 | 'secret' => $accessToken->getSecret(),
|
142 |
| - 'oauth_client' => $oAuthClient, |
| 103 | + 'oauth_client' => $oauthClient, |
143 | 104 | 'integration' => $integration,
|
144 | 105 | ];
|
145 | 106 | }
|
|
0 commit comments