Get Access token for the API
Call this when being redirected from shopify page ( to the $redirectUrl) after authentication

@throws SdkException if SharedSecret or ApiKey is missing in SDK configuration or request is not valid

@return string
348425
public static function getAccessToken()
    {
        $config = ShopifySDK::$config;

        if(!isset($config['SharedSecret']) || !isset($config['ApiKey'])) {
            throw new SdkException("SharedSecret and ApiKey are required for getting access token. Please check SDK configuration!");
        }

        if(self::verifyShopifyRequest()) {
            $data = array(
                'client_id' => $config['ApiKey'],
                'client_secret' => $config['SharedSecret'],
                'code' => $_GET['code'],
            );

            $response = HttpRequestJson::post($config['AdminUrl'] . 'oauth/access_token', $data);

            return isset($response['access_token']) ? $response['access_token'] : null;
        } else {
            throw new SdkException("This request is not initiated from a valid shopify shop!");
        }
    }
1162220
public function getApi()
    {
        if (!isset($this->_api)) {
            $this->_api = ComConnectHelperApi::getApi($this->get('api'));
            $this->_api->setToken($this->tokenKey, $this->tokenSecret);
        }

        return $this->_api;
    }
1069547
public function getAccessToken() {
        if (!empty($this->accessToken)) {
            return $this->accessToken;
        }
        $accessToken = $this->sessionStorage->read('access_token');
        if (!empty($accessToken)) {
            $this->accessToken = $accssToken;
            return $this->accessToken;
        }

        $this->exchangeToken();

        return $this->accessToken;
    }
1126625
public function getPayURedirectUrl()
    {
        $mode = parent::$apiContext->get('mode');
        $reference = $this->return->payUReference;

        if (!$mode || !$reference)
            return null;

        $url = sprintf(self::REDIRECT_URL, $mode === 'sandbox' ? 'staging' : 'secure', $reference);

        return $url;
    }
383992
public function getCustomServiceKFlist(){
        if (!$this->access_token && !$this->checkAuth()) return false;
        $result = $this->http_get(self::API_URL_PREFIX.self::CUSTOM_SERVICE_GET_KFLIST.'access_token='.$this->access_token);
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            return $json;
        }
        return false;
    }
726002
public function getLoginUrl()
    {
        // required params
        $params = array(
            'client_id' => $this->getClientId(),
            'redirect_uri' => $this->getRedirectUri(),
        );
        // optional params
        if ($this->getScope()) {
            $params['scope'] = implode(',', $this->getScope());
        }
        if ($this->getResponceType()) {
            $params['response_type'] = $this->getResponceType();
        }
        if ($this->apiVersion) {
            $params['v'] = $this->apiVersion;
        }
        if ($this->state) {
            $params['state'] = $this->state;
        }

        return 'https://oauth.vk.com/authorize?' . http_build_query($params);
    }
1245832
public function getAuthoriseUrl()
    {
        $clientId = $this->_scopeConfig->getValue(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CLIENT_ID
        );

        //callback uri if not set custom
        $redirectUri = $this->helper->getRedirectUri();
        $redirectUri .= 'connector/email/callback';

        $adminUser = $this->auth->getUser();

        //query params
        $params = [
            'redirect_uri' => $redirectUri,
            'scope' => 'Account',
            'state' => $adminUser->getId(),
            'response_type' => 'code',
        ];

        $authorizeBaseUrl = $this->configHelper
            ->getAuthorizeLink();
        $url = $authorizeBaseUrl . http_build_query($params)
            . '&client_id=' . $clientId;

        return $url;
    }
36021
public function requestAccessToken()
    {
        $tokenUrl = $this->processUrl($this->server->getAccessTokenUrl());
        $accessToken = $this->instance->requestAccessToken($tokenUrl);
        $this->instance->setAccessToken($accessToken);

        return $accessToken;
    }
63056
protected function _getBearerAuthorization()
  {
    if (self::$_consumer_key === null
      && self::$_bearer_token === null
    ) {
      throw new CodebirdCredentialsException('To make an app-only auth API request, consumer key or bearer token must be set.');
    }
    // automatically fetch bearer token, if necessary
    if (self::$_bearer_token === null) {
      $this->oauth2_token();
    }
    return 'Bearer ' . self::$_bearer_token;
  }
335784
public static function getAccessToken()
    {
        if (static::$token) {
            return static::$token;
        }
        $response = static::$httpClient->post(static::GET_TOKEN_ENDPOINT, [
            'form_params' => [
                'client_id' => static::$apiContext->getClientId(),
                'client_secret' => static::$apiContext->getClientSecret(),
                'grant_type' => 'silent',
                'kdt_id' => static::$apiContext->getKdtId(),
            ]
        ]);
        $json = \GuzzleHttp\json_decode((string) $response->getBody(), true);
        $expiresAt = new \DateTime($json['expires_in'] . ' seconds');

        return static::$token = new Token($json['access_token'], $expiresAt);
    }
693255
public function getAccessToken()
    {
        $session = $this->getClient()->getConnector()->getSession();
        $token = $session->get('accessToken');
        $expires = $session->get('expires');
        if (!$token || $expires < time()) {
            // Force a connection to the API to ensure there is an access token.
            $this->getMyAccount(true);
            if (!$token = $session->get('accessToken')) {
                throw new \RuntimeException('No access token found');
            }
        }

        return $token;
    }
861148
public function getRequestToken()
    {
        return md5($this->getMerchantId().$this->getProductId().$this->getAmount().$this->getTransactionId().$this->getPhone().$this->getSecretWord());
    }
415780
private function getAuthCode()
    {
        $amount = intval($this->parameters['amount']);
        if (!$this->sandbox) {
            $url = $this->endpoint . "/Auth/{$this->parameters['custom']}/{$this->parameters['transactionId']}/{$amount}";
            $url_redirect = $this->endpoint_redirect;
        } else {
            $url = $this->sandbox_endpoint . "/Auth/{$this->options['app_key']}/{$this->parameters['transactionId']}/{$amount}";
            $url_redirect = $this->sandbox_endpoint_redirect;
        }
        $response = $this->xml2array($this->curl_request($url));
        $output = explode('|', $response['0']);
        if ($output['0'] != 1) {
            throw new \Exception($output['1']);
        }

        $this->transactionReference = $output['2'];
        $this->auth_code = $output['3'];
        $this->redirect = $url_redirect . '?AuthCode=' . $this->auth_code;
    }
1167860
public function getAccessToken($code, $callback_url = 'https://api.vk.com/blank.html')
    {
        if (!is_null($this->access_token) && $this->auth) {
            throw new VKException('Already authorized.');
        }

        $parameters = array(
            'client_id' => $this->app_id,
            'client_secret' => $this->api_secret,
            'code' => $code,
            'redirect_uri' => $callback_url
        );

        $rs = json_decode($this->request(
            $this->createUrl(self::ACCESS_TOKEN_URL, $parameters)), true);

        if (isset($rs['error'])) {
            throw new VKException($rs['error'] .
                (!isset($rs['error_description']) ?: ': ' . $rs['error_description']));
        } else {
            $this->auth = true;
            $this->access_token = $rs['access_token'];
            return $rs;
        }
    }
1215399
public function getAuthoriseUrl()
    {
        // Get the request token
        $token = $this->getToken();
    
        // Prepare request parameters
        $params = array(
            'oauth_token' => $token->oauth_token,
            'oauth_token_secret' => $token->oauth_token_secret,
            'oauth_callback' => $this->callback,
        );
    
        // Build the URL and redirect the user
        $query = '?' . http_build_query($params, '', '&');
        $url = self::WEB_URL . self::AUTHORISE_METHOD . $query;
        return $url;
    }
1000514
public function getRequestToken()
    {
        return md5($this->getMerchantId().$this->getTransactionReference().$this->getAmount().$this->getSecretWord());
    }
380915
public function getAuthorizeUrl () {
		return sprintf('%s%s?%s', $this->host, $this->authorizePath, http_build_query([
			'response_type'			=> $this->code ?? static::RESPONSE_TYPE_CODE,
			'client_id'				=> $this->clientId,
			'redirect_uri'			=> $this->redirectUri,
			'scope'					=> implode(' ', (array) $this->scope),
			'state'					=> $this->state,
			'code_challenge'		=> $this->codeChallenge,
			'code_challenge_method'	=> $this->codeChallengeMethod ?? static::CODE_CHALLENGE_METHOD_SHA256,
		]));
	}