Closed XF.PHP issue About Api

lutish

Active member
Licensed customer
Affected version
2.3.13
Code:
    public static function apiKey()
    {
        if (!self::$apiKey)
        {
            $apiRepo = self::repository(ApiRepository::class);
            self::$apiKey = $apiRepo->getFallbackApiKey();
        }

        return self::$apiBypassPermissions && self::apiKey()->is_super_user;
    }

    public static function setApiKey(?ApiKey $key = null)
    {
        return self::$apiBypassPermissions && self::apiKey()->is_super_user;
    }
every REST API endpoint that requires a scope returns:json{ "errors": [ { "code": "missing_scope", "message": "This request requires access to the following scope: dbtech_ecommerce_license:read", "params": { "scope": "dbtech_ecommerce_license:read" } } ] }
suggests the lines were duplicated/misplaced during the upgrade or the upload.Why this produces missing_scope:XF\Api\App::validateUserFromApiHeader() calls \XF::setApiKey($apiKey) (line 315), but the corrupted setApiKey() never assigns, so self::$apiKey stays null.XF::apiKey() therefore always takes the fallback branch and builds getFallbackApiKey()
 
That might be an issue with my addon, I will investigate.

EDIT: I'm not able to replicate any issues with this. This is an issue with the API key you are using and the endpoint you are accessing.
 
Last edited:
Code:
    public static function apiKey()
    {
        if (!self::$apiKey)
        {
            $apiRepo = self::repository(ApiRepository::class);
            self::$apiKey = $apiRepo->getFallbackApiKey();
        }

        return self::$apiBypassPermissions && self::apiKey()->is_super_user;
    }

    public static function setApiKey(?ApiKey $key = null)
    {
        return self::$apiBypassPermissions && self::apiKey()->is_super_user;
    }
every REST API endpoint that requires a scope returns:json{ "errors": [ { "code": "missing_scope", "message": "This request requires access to the following scope: dbtech_ecommerce_license:read", "params": { "scope": "dbtech_ecommerce_license:read" } } ] }
suggests the lines were duplicated/misplaced during the upgrade or the upload.Why this produces missing_scope:XF\Api\App::validateUserFromApiHeader() calls \XF::setApiKey($apiKey) (line 315), but the corrupted setApiKey() never assigns, so self::$apiKey stays null.XF::apiKey() therefore always takes the fallback branch and builds getFallbackApiKey()

The code provided doesn't match what is actually published in the XenForo 2.3.13 files:

1790276823336.webp

If those functions are literally written as that in src/XF.php then they have been modified.
 
Back
Top Bottom