Skip to content

Call to a member function getServiceUrl() on null #330

Description

@jjj117

OpenStack\Identity\v3\Service::authenticate
vendor/php-opencloud/openstack/src/Identity/v3/Service.php:50

   if (!empty($options['cachedToken'])) {

            $token = $this->generateTokenFromCache($options['cachedToken']);

 

            if ($token->hasExpired()) {

                throw new \RuntimeException(sprintf('Cached token has expired on "%s".', $token->expires->format(\DateTime::ISO8601)));

            }

        } else {

            $token = $this->generateToken($authOptions);

        }

 

        $name      = $options['catalogName'];

        $type      = $options['catalogType'];

        $region    = $options['region'];

        $interface = isset($options['interface']) ? $options['interface'] : Enum::INTERFACE_PUBLIC;

 

        if ($baseUrl = $token->catalog->getServiceUrl($name, $type, $region, $interface)) {

            return [$token, $baseUrl];

        }

 

        throw new \RuntimeException(sprintf('No service found with type [%s] name [%s] region [%s] interface [%s]', $type, $name, $region, $interface));

    }

 

    /**

     * Generates authentication token from cached token using `$token->export()`.

     *

     * @param array $cachedToken {@see \OpenStack\Identity\v3\Models\Token::export}

     */

    public function generateTokenFromCache(array $cachedToken): Models\Token

    {

        return $this->model(Models\Token::class)->populateFromArray($cachedToken);

    }

my code:

 $compute = $openstack->computeV2(['region' => 'default']);
 $images = $compute->listImages(['status' => 'ACTIVE']);

Activity

  1. adamramadhan commented on Jun 14, 2022

    @adamramadhan

    same here

  2. AmirRezaM75 commented on Dec 17, 2024

    @AmirRezaM75

    any update?

  3. vansante commented on Jan 21, 2025

    @vansante

    So I ran into this issue too, apparently its because the auth server does not return a catalog if you don't give it a scope in your settings:

        'scope' => [
            'project' => ['id' => '<project-id>']
        ]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions