7
7
8
8
namespace Zoho \Desk \OAuth ;
9
9
10
- use zcrmsdk \crm \exception \ZCRMException ;
11
- use zcrmsdk \crm \setup \restclient \ZCRMRestClient ;
12
10
use zcrmsdk \crm \utility \APIConstants ;
13
- use zcrmsdk \crm \utility \ZCRMConfigUtil ;
14
11
use zcrmsdk \oauth \exception \ZohoOAuthException ;
12
+ use zcrmsdk \oauth \ZohoOAuth ;
13
+ use zcrmsdk \oauth \ZohoOAuthClient ;
15
14
use Zoho \Desk \Api \Metadata ;
16
15
use Zoho \Desk \Client \ConfigProviderInterface ;
17
16
use Zoho \Desk \Exception \Exception ;
@@ -53,8 +52,10 @@ public function getAccessToken(): string
53
52
{
54
53
try {
55
54
$ this ->configure ();
56
- $ accessToken = ZCRMConfigUtil::getAccessToken ();
57
- } catch (ZCRMException | ZohoOAuthException $ e ) {
55
+ /** @var ZohoOAuthClient $oauthClient */
56
+ $ oauthClient = ZohoOAuth::getClientInstance ();
57
+ $ accessToken = $ oauthClient ->getAccessToken ($ this ->configProvider ->get ()[APIConstants::CURRENT_USER_EMAIL ]);
58
+ } catch (ZohoOAuthException $ e ) {
58
59
throw new Exception ($ e ->getMessage (), $ e ->getCode (), $ e );
59
60
}
60
61
@@ -69,7 +70,7 @@ public function getOrgId(): int
69
70
private function configure (): void
70
71
{
71
72
if (!$ this ->isConfigured ) {
72
- ZCRMRestClient ::initialize ($ this ->configProvider ->get ());
73
+ ZohoOAuth ::initialize ($ this ->configProvider ->get ());
73
74
$ this ->isConfigured = true ;
74
75
}
75
76
}
0 commit comments