|Fantastic effort. Thanks so much, Manuel.|
My problem is that a custom configuration won't redirect back to the URI we're trying to use the access_token on.
It just displays a JSON string at the API server site which looks like this:
It's an OAuth2 restful solution at the other end.
I can send you more details if I can PM/direct message you.
I would commission you to make this work.
Do you take on jobs?
Vu Online Ltd
|2013-02-27 19:53:42 - In reply to message 1 from Marcus Link|
|...and of course I would appreciate if you have any idea what's going on. I also tried using append_state_to_redirect_uri but no difference.|
|2013-02-27 20:03:21 - In reply to message 1 from Marcus Link|
|It is hard to tell without seeing the documentation of that OAuth server and what exactly what you are setting in the configuration.|
Is this server publicly documented?
|2013-02-27 21:04:34 - In reply to message 3 from Manuel Lemos|
|It's a partner API utilizing OAuth, Restful endpoints, and JSON.|
This redirect issue arises when using your test_oauth_client.php: it forwards us to server and returns the correct response on screen. That's it.
This much I can pass on:
... OAuth process which follows the OAuth 2.0 specifications and presents all its processes in a restful state.
Our current OAuth implementation adheres to the following specifications:
 The OAuth 2.0 Authorization Protocol (rev 16)
 The OAuth 2.0 Authorization Protocol: Bearer Tokens (rev 16)
[The API] is completely restful. All endpoints are designed to respond in a restful manor and all status codes returned represent the correct HTTP 1.1 expectations. You can find all information on these at http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html.
RESPONSE DATA FORMAT
[The API] returns data in one of two standardly accepted formats JSON and XML. By default we return JSON, if a request presents the HTTP Header “Accept: application/xml” or “Accept: text/xml” we will send XML instead. We strongly suggest using the default JSON response content type as it is a commonly accepted standard of mobile development. Endpoints take JSON objects under the PUT, DELETE and POST verbs. (see the Endpoints section for more details)
|2013-02-28 00:14:31 - In reply to message 4 from Marcus Link|
|I see but this does not help clarifying the problem.|
OAuth is a protocol standard but each server implements it in different ways that make it work differently.
The class provides means to adjust certain details of the way each API work but I have way of knowing what details to adjust without seeing in practice what comes from the server. From what you tell me, I can only guess.
It seems that the server redirects back to your script but if the class does not proceed with the protocol, maybe something is missing.
I suspect it can be the state parameter that the class uses to avoid security attacks.
You may want to enable debugging information setting the debug variable and see what appears in the PHP error log.
|2013-02-28 00:32:04 - In reply to message 5 from Manuel Lemos|
|I understand. And, yes, indeed I am logging. Here's an example:|
[27-Feb-2013 17:56:44] OAuth client: Checking if OAuth access token was already retrieved from https://secure.example.com/OAuth/access_token
[27-Feb-2013 17:56:44] OAuth client: Checking the authentication state in URI /api_demos/test_oauth_client.php
[27-Feb-2013 17:56:44] OAuth client: Redirecting to OAuth Dialog https://secure.example.com/OAuth/access_token?client_id=clientid.subdomain.example.com&client_secret=6CD3B809-BEC3-4684-BFC0-26D68A816878&grant_type=client_credentials&scope=RegisterUser&redirect_uri=http%3A%2F%2Fsubdomain.example.com%2Fapi_demos%2Ftest_oauth_client.php
|2013-02-28 01:12:56 - In reply to message 6 from Marcus Link|
|I am still not sure what happens.|
Above you tell that the it displays some JSON structure.
Now you show a log stating that the last thing that happens is redirecting to the server.
Does the browser get redirected to the server? What happens next?
|2013-02-28 11:38:09 - In reply to message 7 from Manuel Lemos|
|I do apologise. It seems I can't upload a screengrab here so I'll describe what I do and get.|
1) I have installed your http and oauth classes and set-up oauth_client.php and test_oauth_client.php as best I can with the data provided by the oauth and API documentation
2) I direct my browser to http://subdomain.mysite.com/api_demos/test_oauth_client.php where it is installed.
3) My browser redirects to this page:
4) and displays this JSON string:
5) The log reads as follows:
[28-Feb-2013 10:21:01] OAuth client: Checking if OAuth access token was already retrieved from https://secure.serverdomain.com/OAuth/access_token
[28-Feb-2013 10:21:01] OAuth client: Checking the authentication state in URI /api_demos/test_oauth_client.php
[28-Feb-2013 10:21:01] OAuth client: Redirecting to OAuth Dialog https://secure.serverdomain.com/OAuth/access_token?client_id=clientid.subdomain.serverdomain.com&client_secret=6CD3B809-BEC3-4684-BFC0-26D68A816878&grant_type=client_credentials&scope=RegisterUser&redirect_uri=http%3A%2F%2Fsubdomain.clientdomain.com%2Fapi_demos%2Ftest_oauth_client.php
|2013-02-28 12:13:55 - In reply to message 8 from Marcus Link|
|It seems you have configured incorrectly the dialog_url variable and set it to URL that should go in the access_token_url variable, so they are probably with switched values.|