Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Curl authorization with access token doesn't work (symfony 4)

$
0
0

Project is reilized with Symfony 4.4 version.

Problem 1 when I move first line in the end, symfony dont require authorization for ^/api urls

access_control:        - { path: ^/api, roles: [ IS_AUTHENTICATED_FULLY ] }        - { path: ^/, role: IS_AUTHENTICATED_ANONYMOUSLY }        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

Problem 2 I use Guzzle client to get access token

$client->request(    POST","http://myurl/oauth/v2/token",    ["form_params" => ["grant_type" => "password","client_id" => "clientid","client_secret" => "clientsecret","username" => "username","password" => "password"    ]  ] )

and get some access token, after try execute this command

curl -i http://myurl/api/register -H "Authorization: Bearer NzJmMmIxZWZhM2YzZDIyNTFlMzMzMzIxZGYxYTc4YjhhMzJkY2M3MTdjZGY2NjZlMTM2ODdkNzdhOTFiM2E2NA" 

and get response Redirecting to login page

In target side I have a firewall like shown in below

api:    pattern:    ^/api    fos_oauth:  true    stateless:  true    anonymous:  false    provider: fos_userbundle

Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>