PHP Classes

Basic Authorization

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Basic Authorization  >  (Un) Subscribe thread alerts  
Subject:Basic Authorization
Summary:Passing a basic HTTP authorization
Messages:4
Author:fdsdsf dsfdsfdsf
Date:2013-10-23 04:40:32
Update:2013-10-23 06:20:53
 

  1. Basic Authorization   Reply   Report abuse  
Picture of fdsdsf dsfdsfdsf fdsdsf dsfdsfdsf - 2013-10-23 04:40:32
Excellent job on this class! It works really well. I do have a slight problem. The page I am accessing requires basic HTTP authentication.

"This request requires HTTP authentication ()"

The format of the header is like the following:
Authorization: Basic CLIENT_ID:CLIENT_SECRET

Is there a way to specify this without modifying the oauth_client.php file?

Thanks!
Aaron

  2. Re: Basic Authorization   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-10-23 05:06:38 - In reply to message 1 from fdsdsf dsfdsfdsf
It does not seem to make much sense what you are saying because OAuth is already a form of authentication. So either you use OAuth or Basic authentication.

The OAuth class uses the HTTP client class which supports Basic authentication, but if you only need to make Basic authentication requests, you only need to use the HTTP client class directly.

phpclasses.org/httpclient

On the other hand, I suspect that you are doing something wrong when using OAuth and the server is falling back to Basic authentication.

Can you please tell what API are you trying to access that requires Basic authentication?

  3. Re: Basic Authorization   Reply   Report abuse  
Picture of fdsdsf dsfdsfdsf fdsdsf dsfdsfdsf - 2013-10-23 05:15:21 - In reply to message 2 from Manuel Lemos
Thank you for your response Manuel!

The API I am accessing is from our local energy utility here. It will give me access to my real-time energy usage.

It does seem strange that they would require HTTP requests to contain basic authentication but that is precisely what their documents say, and is reflective in the error I am receiving:

Error: 401
Description: This request requires HTTP authentication ().

Their documents state that "Authorization: Basic CLIENT_ID:CLIENT_SECRET" is required when making the POST after receiving the code.

  4. Re: Basic Authorization   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2013-10-23 06:20:53 - In reply to message 3 from fdsdsf dsfdsfdsf
Maybe Basic authentication is all it needs, so no OAuth is necessary.

In that case, just use the HTTP client class directly setting the user name and password.