Skip to content

Authentication fails with FORBIDDEN error on unRAID 7.2.3 #45

@Quixotic-Limit

Description

@Quixotic-Limit

Authentication Failed Error with unRAID 7.2.3

Environment

  • unRAID Version: 7.2.3
  • unRAID API Version: 4.28.2+d13a1f61
  • Integration Version: 1.4.0
  • Home Assistant Version: 2026.1.2

Problem Description

The integration fails to authenticate with "Authentication failed" error when setting up, even with a valid API key that has all required permissions (Info, Servers, Array, Disk, Share with Read permissions).

Logs

ERROR (MainThread) [custom_components.unraid_api.config_flow] GraphQL Error response: {'errors': [{'message': 'Forbidden resource', 'locations': [{'line': 3, 'column': 3}], 'path': ['info'], 'extensions': {'code': 'FORBIDDEN', 'originalError': {'message': 'Forbidden resource', 'error': 'Forbidden', 'statusCode': 403}}}], 'data': None}

The error shows a FORBIDDEN response code, but the integration treats this as a generic GraphQL error instead of an authentication error.

Root Cause

In /custom_components/unraid_api/api/__init__.py, the call_api method only checks for UNAUTHENTICATED errors but not FORBIDDEN errors:

if "errors" in result:
    try:
        if result["errors"][0]["extensions"]["code"] == "UNAUTHENTICATED":
            raise UnraidAuthError(response=result)
    except KeyError:
        pass
    raise UnraidGraphQLError(response=result)

Solution

Add handling for FORBIDDEN error code:

if "errors" in result:
    try:
        if result["errors"][0]["extensions"]["code"] == "UNAUTHENTICATED":
            raise UnraidAuthError(response=result)
        if result["errors"][0]["extensions"]["code"] == "FORBIDDEN":
            raise UnraidAuthError(response=result)
    except (KeyError, IndexError):
        pass
    raise UnraidGraphQLError(response=result)

Verification

After applying this fix, the integration successfully authenticates and connects to the unRAID server.

Additional Notes

The API key works correctly when tested directly with curl:

curl -H "x-api-key: YOUR_API_KEY" -H "Content-Type: application/json" http://YOUR_SERVER/graphql -d '{"query":"{ info { versions { core { api } } } }"}'

This returns valid data, confirming the API key has proper permissions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions