Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API auth token null #587

Open
michelson opened this issue Dec 28, 2020 · 5 comments
Open

API auth token null #587

michelson opened this issue Dec 28, 2020 · 5 comments

Comments

@michelson
Copy link

Hi, I've followed the example on the Pow guides for API auth, it's working but the responses on registrations an sessions urls are giving an empty access token, like {"data":{"access_token":null,"renewal_token":null}} I guess it has something to do with the CredentialsCache or the PersistentSessionCache but I don't know really how to debug this.

using {:pow, "> 1.0.21"} and phoenix {:phoenix, "> 1.5.7"}

@ajstrand
Copy link

ajstrand commented Jan 8, 2021

@danschultzer I am also seeing this same issue when I try to test the api endpoionts.

when I try to run the first curl request

 curl -X POST -d "user[email][email protected]&user[password]=secret1234&user[password_confirmation]=secret1234" http://localhost:4000/api/v1/registration

the result I get is:

{"data":{"access_token":null,"renewal_token":null}}                                                                                                                                  

any advice on to proceed in debugging this?

I have not made any other modifications other than using the API auth guide in the docs.

@danschultzer
Copy link
Collaborator

danschultzer commented Jan 31, 2021

Sorry for the late reply!

There was a significant change in the API guide a while a ago with #454 where the naming was changed for the conn.private keys from auth_token to access_token and renew_token to renewal_token. Could this be the reason it doesn't work?

I would run IO.inspect(conn.private) to debug this. If there is no token keys set at all, then I imagine it's because the API plug isn't running and you should verify that that plug MyAppWeb.APIAuthPlug, otp_app: :my_app is in the right place in the router/endpoint (and you are not calling plug Pow.Plug.Session subsequently).

@ajstrand
Copy link

ajstrand commented Feb 4, 2021

@danschultzer that's certainly possible that what you're describing could be the issue. I was on deadline of sorts(take-home project for an interview, so I switched to a different auth solution(phx.gen.auth).

I can spin up an example app using Pow this weekend though and see if what you suggested would fix the issue. Thanks for responding.

@danschultzer
Copy link
Collaborator

Yeah, this sounds like a frustrating issue. I would be happy to see if you can replicate this issue. I've opened #597 to ensure that an error is raised if the keys are not set.

@michelson
Copy link
Author

Hi, @danschultzer, it seems this issue is still happening. I've debugged a bit and the Api plug is never called as you mentioned. also, in the docs is stated that we have to remove the plug Pow.Plug.Session, otp_app: :myapp from the endpoint, but when I remove that line I get another error:

** (Pow.Config.ConfigError) Pow configuration not found in connection. Please use a Pow plug that puts the Pow configuration in the plug connection.
code: conn = pos

I'm using the latest pow, ~> 1.0.26 and the latest tutorial code, still no luck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants