Nodes/OmniNodes/OAuth2 Token Manager (WebAPI)
ComfyUI Node

OAuth2 Token Manager (WebAPI)

Grab an OAuth2 token inside the graph for API-heavy workflows

By TensorVizion·Created 3 months ago·Updated about 8 hours ago· 0
OAuth2 Token Manager (WebAPI)
    • access_token
    • refresh_token
    • expires_at
    • token_type
    token_urlhttps://oauth2.googleapis.com/token
    client_idyour_client_id
    client_secretyour_client_secret
    grant_type
    scope
    username
    password
    timeout10.00

    If you've ever wired ComfyUI up to a paid API, you know the chore: every request needs an access token, tokens expire, and your workflow breaks the moment one does. OAuth2 Token Manager (WebAPI) automates the boring part - it hits your provider's token endpoint and hands back an access token you can wire straight into the pack's HTTP Request node. No more pasting a token from a browser tab into a widget.

    The name is accurate and the mechanism is standard: it speaks the OAuth2 client-credentials or password grant against any token URL. It does not run a model, it does not hold state, it just does the token dance and returns the pieces.

    How it works

    You give it token_url (defaults to Google's OAuth2 endpoint, so change it to your provider's), client_id, client_secret, and pick grant_type - client_credentials for server-to-server auth (most common, no username needed), or password for resource-owner flows where you also supply username/password. Optional scope goes through when set, and timeout defaults to 10 seconds.

    It returns four outputs: access_token (the bearer token your requests need), refresh_token (when the provider issues one), expires_at (a unix timestamp for when it dies), and token_type (usually "Bearer"). Wire access_token into your HTTP Request's Authorization header - the JSON you build can reference it directly.

    The gotcha worth knowing

    Errors don't crash the queue. If the token request fails, exceptions are caught and surfaced as an "Error: ..." string inside the token_type output. That's deliberate - a dead credential shouldn't kill the whole workflow - but it means you should actually look at that output when things go sideways, because a failed auth will present as an auth error at the HTTP Request node downstream, and the real cause is sitting in token_type.

    Also: this is a Web API category node, which is the one corner of OmniNodes with a real dependency. It needs the requests library, which ComfyUI does not bundle.

    Installing it

    cd ComfyUI/custom_nodes/
    git clone https://github.com/TensorVizion/OmniNodes
    cd OmniNodes
    pip install -r requirements.txt
    

    Then restart ComfyUI (ComfyUI Manager users: search "OmniNodes"; the requirements step still applies). Skip the pip line and this node will fail to import with ModuleNotFoundError: No module named 'requests' - install into the same Python environment ComfyUI runs in.

    The security note, because the KB's external-API doc hammers it: your client_secret (and password, if you use the password grant) sits in plaintext in the workflow file. Anyone who gets that file has your credentials. Treat this workflow like a keychain, not a screenshot to share. And remember the token in the workflow is only as fresh as the last run - expires_at tells you when you'll need to hit the queue again.

    CategoryTensorVizion/Web API

    Inputs (8)

    NameTypeDefaultDescription
    token_urlSTRINGhttps://oauth2.googleapis.com/token
    client_idSTRINGyour_client_id
    client_secretSTRINGyour_client_secret
    grant_typeCOMBO2 options: client_credentials, password
    scopeoptSTRING
    usernameoptSTRING
    passwordoptSTRING
    timeoutoptFLOAT10.00

    Outputs (4)

    NameTypeDescription
    access_tokenSTRING
    refresh_tokenSTRING
    expires_atSTRING
    token_typeSTRING