Skip to content

Auth Interceptor #323

Answered by lbensaad
lbensaad asked this question in Q&A
Discussion options

You must be logged in to vote

I solved it with this interceptor

export const auth: Interceptor = (next) => async (req) => {    
    try {
        return await next(req);
    } catch (error) {
        if(error instanceof ConnectError){
            if(error.code === Code.Unauthenticated){
                await refreshToken()
                return  await next(req);
            }    
        }
        throw error
    }
};

But the connect-go server has to return the error with:
connect.NewError(connect.CodeUnauthenticated, err)

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lbensaad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant