I'm running PHP 5.3.6 as Apache 2 module (phpinfo ServerAPI says "Apache 2.0 Filter") in a Ubuntu machine. I have a PHP application and I want a iOS client to send it information under https. Concretely, I want to send a oAuth2 token in Authorization header, using:

Authorization: Bearer XXXXXXXXX

Being XXXXXXXXX the Base64 encoding of a oAuth2 token.

The request is sent from the iOS client properly (I can see the request header with my Authorization string), and I can see it when it reachs the server by executing getallheaders.

My problem is I don't know if I'm being conceptually correct. When I use Basic authentication, I can get user and password by $_SERVER['PHP_AUTH_USER"] and $_SERVER['PHP_AUTH_PW']. But here, I'm getting just the raw 'Authorization' value of the array that getallheaders returns. Sounds like 'dirty' to me.

Is there another different way of getting the token in my server? I just want to store it in a database, and use it later to make API calls to the token provider on behalf of my clients.

Many thanks in advance, and best regards


1 Answer 1


Unfortunately, PHP tries to be intelligent and tries to parse the Authorization-Header.

You can use getallheaders() to get to the raw header data, but that's not available in some SAPI's (in my case, it's not available in PHP-FPM).

The only way I can see to still get to the data is to create another variable on the server-end and pass it through (like X-Authorization-Copy or whatever). This is pretty much server-dependent though.

  • I finally used getallheaders(). Thanks for your response. And for your advice with the SAPI's. Aug 1, 2012 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.