Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
I finally used getallheaders(). Thanks for your response. And for your advice with the SAPI's. –  jorgeas80 Aug 1 '12 at 10:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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