77
88namespace Zoho \Desk \OAuth ;
99
10- use zcrmsdk \crm \exception \ZCRMException ;
11- use zcrmsdk \crm \setup \restclient \ZCRMRestClient ;
1210use zcrmsdk \crm \utility \APIConstants ;
13- use zcrmsdk \crm \utility \ZCRMConfigUtil ;
1411use zcrmsdk \oauth \exception \ZohoOAuthException ;
12+ use zcrmsdk \oauth \ZohoOAuth ;
13+ use zcrmsdk \oauth \ZohoOAuthClient ;
1514use Zoho \Desk \Api \Metadata ;
1615use Zoho \Desk \Client \ConfigProviderInterface ;
1716use Zoho \Desk \Exception \Exception ;
@@ -53,8 +52,10 @@ public function getAccessToken(): string
5352 {
5453 try {
5554 $ 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 ) {
5859 throw new Exception ($ e ->getMessage (), $ e ->getCode (), $ e );
5960 }
6061
@@ -69,7 +70,7 @@ public function getOrgId(): int
6970 private function configure (): void
7071 {
7172 if (!$ this ->isConfigured ) {
72- ZCRMRestClient ::initialize ($ this ->configProvider ->get ());
73+ ZohoOAuth ::initialize ($ this ->configProvider ->get ());
7374 $ this ->isConfigured = true ;
7475 }
7576 }
0 commit comments