go-vue-starter icon indicating copy to clipboard operation
go-vue-starter copied to clipboard

Error on getting userinfo

Open gustavosooeiro opened this issue 7 years ago • 6 comments

Hi,

I've just downloaded your code to learn about go and jwt. When trying to access the userinfo api i received a message, that I could not figure what is the problem. I hope you can help me undestand:

[negroni] PANIC: interface conversion: interface {} is nil, not *jwt.Token

gustavosooeiro avatar Jun 27 '17 17:06 gustavosooeiro

/api/users/info is a protected route. It sounds like you are trying to access with endpoint without a token. You must login an existing user or create a new one. Both actions will return a token that can be used to access protected routes. Try following the instructions in the readme. You must first start the Go server backend. For the frontend you can either create a production build or run a separate development server. Then access the web site with your browser. Hope that helps.

markcheno avatar Jun 27 '17 19:06 markcheno

I did everything you just said Mark. I was logged in. I've got this error just trying to access the route, when clicked in the user info menu link. So, as I am logged in, the problem must be that there somewhere in the code the token is not been passed correctly. I just cant say where exactly. Can you tell? I haven't changed anything in your code!

gustavosooeiro avatar Jun 27 '17 21:06 gustavosooeiro

I believe it is fixed now. Please pull the latest code and try again. The problem was an update to the jwt middleware software I used.

markcheno avatar Jun 28 '17 03:06 markcheno

Still the same error :(

gustavosooeiro avatar Jun 28 '17 15:06 gustavosooeiro

I'm sorry, without more information, I can't tell what the problem is. I was able to duplicate your error, but it is now fixed for me. Perhaps try a "go get -u ./..." in the project root. Then restart everything.

markcheno avatar Jun 29 '17 00:06 markcheno

I've seen this exact same issue. In my case, I'd used go modules to pull down the dependencies. After much debugging I eventually discovered that the version of JWT middleware I was using wasn't the latest! I had somehow managed to grab a version from 2016-04

v0.0.0-20160421215738-f3f7de3b9e39

After coaxing go modules to get the latest version from 2017-04

v0.0.0-20170425171159-5493cabe49f7

the problem I was having with getting userinfo was resolved.

blogscot avatar Apr 24 '19 14:04 blogscot