Hi

I have the blow code in my C# app:

var clientHandler = new HttpClientHandler();
var client = new HttpClient(clientHandler);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Your Oauth token");

How can I access this Authorization key in my backend's PHP?

Thanks,
Jassim

    Request headers will be found in the $_SERVER array, with a name prefixed with HTTP__.

      I am going to use:

      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("key", "=" + apiKey);
      so how can I use the $_SERVER?

      The sample I have on PHP manual is:

      if( ( isset($_SERVER['PHP_AUTH_USER'] ) && ( $_SERVER['PHP_AUTH_USER'] == "leon" ) ) AND
          ( isset($_SERVER['PHP_AUTH_PW'] ) && ( $_SERVER['PHP_AUTH_PW'] == "secret" )) )

        You can inspect the contents of any variable in PHP using var_dump or print_r. Have a look at the contents of $_SERVER and you might see the values you are interested in:

        var_dump($_SERVER);

        If you don't want to show this information in a browser, you can have PHP write it to some temporary file:

        file_put_contents('/tmp/file.txt', print_r($_SERVER, true));

        And then you can inspect the contents of /tmp/file.txt to see what you get.

          Write a Reply...