sdiaz / FOSRestBundleByExample

FOSRestBundle example project with Symfony 2.6 standard distribution
MIT License
106 stars 31 forks source link

Unauthorized? #23

Closed robbanl closed 8 years ago

robbanl commented 8 years ago

Hello,

I have some problems reaching resources requiring authentication.

Using FosUserBundle and have a user created. Copied your controller methods for fetching salt, getting token and fetching information about a user.

What I do:

  1. Fetch the user salt - Returns the same salt stored in the database (GET /api/v1/user/users/myusername/salt.json)
  2. Fetch WSSE token using username, password and salt - Returns an array with X-WSSE (POST /api/v1/tokens.json)
  3. Try to fetch information about user (GET /api/v1/user/users/myusername.json)

cURL headers are set with:

$headers = [
    CURLOPT_HTTPHEADER => (array)json_decode($tokenRequest->getContent())
];

Still I get error 401: You are not authenticated.

Also tried generating a WSSE token using CLI tool

php app/console app:token:create myusername mysecretpassword

Have I missed some really basic stuff?

Thanks!

robbanl commented 8 years ago

Did some digging and the following error appears in the logs...

The security context was not populated with a Token
robbanl commented 8 years ago

Closing this issue in favor of issue #19

skyjooy commented 7 years ago

I have the same problem. Any issues ?