Auth client in Next server actions - always getting 401
Hi!
I'm trying to use the auth client in a next server action, but any api I hit on the server side is always unauthorized.  Is there some way to configure the auth client with the user's server-side session?
I know I can do 
auth.api.doThing but I'd greatly prefer to use the auth client for the sake of consistency.
Also, I know I can run these on the client, but there is a very specific reason this specific call is on the server.
3 Replies
Don't use auth client in server actions
Thats only for client side
I don't see why you wouldn't want to use it server side
yeah i had that 
auth.api version working already, was just checking if there was a way.  thanks for the reply.
I don't see why you wouldn't want to use it server sideto maintain a unified api across environments. if the api footprint was exactly the same, and only the client initialization / reference was different, that would be one thing, but they're totally distinct APIs that you and any coworkers need to grok, depending on what env context they're in at the time if
auth.api and authClient had the same exact footprint, i wouldn't think twice about it 
eg: auth.api.organization.create() would be equivalent, but from glancing at the types,  it seems to just have all of the functions directly on auth.api for server side, but not for authClientAh right I see what you mean
I do also wish that for server apis it did follow the api.plugin_name.function
but unfortunately not really possible; auth client is meant for client side, auth.api is meant for server side strictly