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

Authorization header on request to ressource server #926

Open
nottavi opened this issue Apr 5, 2018 · 2 comments
Open

Authorization header on request to ressource server #926

nottavi opened this issue Apr 5, 2018 · 2 comments

Comments

@nottavi
Copy link

nottavi commented Apr 5, 2018

Hi

Once I retrieved an access_token I am trying to get a ressource through an ajax request.
I pass the access_token in the request header

Authorization: Bearer the_access_token

I have 401 all the time. Does the ressource server accept this way to pass the access_token or should I send (which I find less secure and inelegant) the access_token in query string ?

I'm not sure I will receive an answer as this repo seems abandoned, but if someone could confirm it would be great

Thank you

@reb3r
Copy link

reb3r commented May 8, 2018

Which Webserver do you use? For an setup with apache, following entry to my .htaccess helped me:

# Make Bearer Auth-Header available to PHP Backend (needed for OAUTH2) RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

Also make sure you enabled mod_rewrite...

@nottavi
Copy link
Author

nottavi commented May 9, 2018

Thanks @reb3r finally my issue was linked to the preflight request on an ajax POST.
I've added the line in my .htaccess also and handled the preflight request in my Resource Controller, by doing nothing in that case

$request = OAuth2\Request::createFromGlobals(); if( $_SERVER["REQUEST_METHOD"] === "OPTIONS" ): // Do we have to do something here ? else: // Handle the request if (!$server->verifyResourceRequest($request)) { $server->getResponse()->send(); die; } endif;

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

2 participants