Skip to content

Should Geckos allow headers to be set in authorization? #91

Answered by yandeu
trezy asked this question in Help / Questions
Discussion options

You must be logged in to vote

I don't fully understand your question. But can't you just do something like this?

// client
const channel = geckos({ authorization: 'SECRET_CLIENT_TOKEN' })

// server
const io = geckos({
  authorization: async (auth, request) => {
    const clientToken = auth // SECRET_CLIENT_TOKEN

    const res = await requestToFirebase({ token: clientToken })

    if (res.status === 200 && res.email && res.emailIsVerified) return res

    return 401 // unauthorized
  }
})

io.onConnection(channel => {
  console.log(channel.userData) // will be whatever is in "res"
})

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@trezy
Comment options

@yandeu
Comment options

@trezy
Comment options

@yandeu
Comment options

Answer selected by trezy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants