src/MediaServices/Authentication/AzureAdClient.php
public function acquireTokenWithAsymmetricKey($resource, $credentials)
    {
        $method = Resources::HTTP_POST;
        $headers = [];
        $queryParams = [];
        $postParameters = [];
        $statusCode = Resources::STATUS_OK;

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_CLIENT_ASSERTION_TYPE,
            'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_RESOURCE,
            $resource
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_GRANT_TYPE,
            'client_credentials'
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_SCOPE,
            'openid'
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_CLIENT_ASSERTION,
            $this->encodeCertificateAsJWT($credentials)
        );

        $response = $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParameters,
            Resources::EMPTY_STRING,
            $statusCode
        );

        $data = $this->dataSerializer->unserialize($response->getBody());

        $accessToken = $data['access_token'];
        $expirationTime = time() + intval($data['expires_in']);
        return new AccessToken($accessToken, $expirationTime);
    }
public function acquireTokenWithAsymmetricKey($resource, $credentials)
    {
        $method = Resources::HTTP_POST;
        $headers = [];
        $queryParams = [];
        $postParameters = [];
        $statusCode = Resources::STATUS_OK;

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_CLIENT_ASSERTION_TYPE,
            'urn:ietf:params:oauth:client-assertion-type:jwt-bearer'
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_RESOURCE,
            $resource
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_GRANT_TYPE,
            'client_credentials'
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_SCOPE,
            'openid'
        );

        $postParameters = $this->addPostParameter(
            $postParameters,
            Resources::OAUTH_CLIENT_ASSERTION,
            $this->encodeCertificateAsJWT($credentials)
        );

        $response = $this->sendHttp(
            $method,
            $headers,
            $queryParams,
            $postParameters,
            Resources::EMPTY_STRING,
            $statusCode
        );

        $data = $this->dataSerializer->unserialize($response->getBody());

        $accessToken = $data['access_token'];
        $expirationTime = time() + intval($data['expires_in']);
        return new AccessToken($accessToken, $expirationTime);
    }
public function acquireTokenWithAsymmetricKey ( $ resource , $ credentials ) { $ method = Resources :: HTTP_POST ; $ headers = [ ] ; $ queryParams = [ ] ; $ postParameters = [ ] ; $ statusCode = Resources :: STATUS_OK ; $ postParameters = $ this -> addPostParameter ( $ postParameters , Resources :: OAUTH_CLIENT_ASSERTION_TYPE , 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer' ) ; $ postParameters = $ this -> addPostParameter ( $ postParameters , Resources :: OAUTH_RESOURCE , $ resource ) ; $ postParameters = $ this -> addPostParameter ( $ postParameters , Resources :: OAUTH_GRANT_TYPE , 'client_credentials' ) ; $ postParameters = $ this -> addPostParameter ( $ postParameters , Resources :: OAUTH_SCOPE , 'openid' ) ; $ postParameters = $ this -> addPostParameter ( $ postParameters , Resources :: OAUTH_CLIENT_ASSERTION , $ this -> encodeCertificateAsJWT ( $ credentials ) ) ; $ response = $ this -> sendHttp ( $ method , $ headers , $ queryParams , $ postParameters , Resources :: EMPTY_STRING , $ statusCode ) ; $ data = $ this -> dataSerializer -> unserialize ( $ response -> getBody ( ) ) ; $ accessToken = $ data [ 'access_token' ] ; $ expirationTime = time ( ) + intval ( $ data [ 'expires_in' ] ) ; return new AccessToken ( $ accessToken , $ expirationTime ) ; }
Get access token using an asymmetric key

@param string $grantType    OAuth request grant_type field value
@param string $credentials  Asymmetrict Credentials

@return OAuthAccessToken
Get access token using an asymmetric key