N
N
Nube2018-08-02 10:35:26
go
Nube, 2018-08-02 10:35:26

How does the server get the jwt from the client?

For me, the following is magic:
I need to get the jwt when a user requests a page from me.
Where can I extract the jwt from the request?
If so, how does the browser know that I need to pass jwt ?
I sketched out a pseudo-code code to more accurately explain my idea
when the user enters the address, I meet him with the IndexHandler functions
and check if there are jwt GetClientToken () functions, but I don’t know how to check for the presence of a token (

func IndexHandler(writer http.ResponseWriter, request *http.Request) {

  if request.Method != "GET"{	return}else {

    // проверить наличие и валидность токена
    token,res := utils.GetClientToken()

    if res != true {
      render.DefaultIndexRender(writer)
      return
    }
    // если токен есть извлекаем из него данные
    uid,err := utils.DecodeJWT(token)
    if err != nil {}
    render.IndexRender(uid,writer)

  }

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
awesomer, 2018-08-02
@Nube

Read the documentation for your particular server.
Usually not in the request, but in http-header˛ under the name Authorization
https://stackoverflow.com/questions/11068892/oauth...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question