Optional Auth on API endpoint

Options

What would be the best way to allow auth + non auth users access the same endpoint and adapt function stack accordingly? (e.g. conditional doing one thing for auth users, other thing for non auth requests to that endpoint)

Comments

  • nocodetalks
    nocodetalks Member ✭✭
    Options

    Instead of default authentication, use the authentication inside the if-else.

  • tbb
    tbb Member
    Options

    I was trying to use Conditional with auth.id condition but auth is not avaiable unless I enable default auth on the endpoint.

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    If you want to use built-in authentication, the endpoint needs to have Xano pre-process it. If you want shared functionality for auth/nonauth, I would do it with two endpoints that both call a common function.

  • Chris Coleman
    Chris Coleman Administrator

    ADMIN

    Options

    Exactly as Ray described. Because our authentication tokens are encrypted, there isn't a method to decrypt them at this time. We can definitely look into adding support for this, though. Can you please submit a feature request here? Thank you!