Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wiki section "Developing an OAuth 2.0 authorization server" contains incorrect code... #66

Closed
ghost opened this issue Jun 1, 2013 · 20 comments

Comments

@ghost
Copy link

ghost commented Jun 1, 2013

The method "action_access_token" does not seem to compile correctly under Laravel 4.

Here is the screenshot:

image

@jnbdz
Copy link

jnbdz commented Jun 1, 2013

I ran into the same problem.

To debug it I just comment out the code that was causing issue. To try to get to the root of the problem.

Then I found multiple bugs:

  1. First is the models call

            $this->authserver = new League\OAuth2\Server\Authorization(
                     new League\OAuth2\Server\Storage\PDO\Client($db),
                     new League\OAuth2\Server\Storage\PDO\Session($db),
                     new League\OAuth2\Server\Storage\PDO\Scope($db)
             );
    

That's the solution... This is found in the __construct method.

  1. The next bug is found on line 30.

    $this->authserver->addGrantType(new League\OAuth2\Server\Grant\AuthCode($this->authserver));

I am not sure this is the solution... But it stop the error message for this.

  1. Now to debug the first problem.

Solutions:

 'error'                 => $this->authserver->getExceptionType($e->getCode()),

Then you will incouter another error... Here is the solution:

 header($this->authserver->getExceptionHttpHeaders($this->authserver->getExceptionType($e->getCode())));

I hope it helps.

By the way you will encounter another problem.

Non-library specific error.

I am trying to figure it out.

@jnbdz
Copy link

jnbdz commented Jun 1, 2013

The next problem I got as to do with the $server variable. That is for some reason undefined.

The the $server var is supposed to have this value: $this->authserver.

Now I am still incoutering some issues. I am not sure I understand them... But when I do I will add new information.

@ghost
Copy link
Author

ghost commented Jun 3, 2013

Thanks fella for looking into it.

Does this mean that taking care of one issue raises another and you still have not been able to make it work from the wiki ?

I am not able to atleast :( ...

@jnbdz
Copy link

jnbdz commented Jun 3, 2013

The problem is that I am not sure how to test out the code to see if everything is ok.

@ghost
Copy link
Author

ghost commented Jun 3, 2013

Why is not the creator to this package helping us out ? I am sure he is the best person to sort this through :(

@jnbdz
Copy link

jnbdz commented Jun 3, 2013

Busy... Who knows. But I am trying different things on my server. When I get it to work I will explain here how I did it.

@ghost
Copy link
Author

ghost commented Jun 3, 2013

Okay, that would be great. Amazing no one has found this out before. It's the first tutorial in the wiki ...

@esolitos
Copy link

esolitos commented Jun 3, 2013

The wiki is sort of a "pseudocode", you need to set it up based on your Framework.
For example I'm modifying it to work with CodeIgniter, I still have some issues, but it seems to work.

@ghost
Copy link
Author

ghost commented Jun 3, 2013

Help me out with Laravel then :( ... Anyone ?

@jnbdz
Copy link

jnbdz commented Jun 3, 2013

I am! Today I some things to do. But tonight I will be working on it. And when I am done I will give more details on how to setup this package with Laravel 4.

Right now I am trying out OAuth2-client so that I can test it out with OAuth2-server.

The problem is that this package is just a framework to help you create a OAuth2-server. It does not have all the views and other things. You have to coded yourself. The reason, I think, it was to make this package as framework agnostic as possible. But trust me when I am done I will put a link to my GitHub with all the details.

@alexbilbie
Copy link
Contributor

Guys, sorry I haven't helped out much, I've just started a new job, am moving house and have no Internet connection yet. Please bear with me.

Emailing from my iPhone like a BOSS

On 3 Jun 2013, at 22:46, Jean-Nicolas Boulay notifications@github.com wrote:

I am! Today I some things to do. But tonight I will be working on it. And when I am done I will give more details on how to setup this package with Laravel 4.

Right now I am trying out OAuth2-client so that I can test it out with OAuth2-server.

The problem is that this package is just a framework to help you create a OAuth2-server. It does not have all the views and other things. You have to coded yourself. The reason, I think, it was to make this package as framework agnostic as possible. But trust me when I am done I will put a link to my GitHub with all the details.


Reply to this email directly or view it on GitHub.

@jnbdz
Copy link

jnbdz commented Jun 3, 2013

@alexbilbie should I continue figuring it out? Or will you post updates that will make what I do obsolete?

@developerNoman another thing. Your controller should extend: "BaseController".

@jnbdz
Copy link

jnbdz commented Jun 4, 2013

@developerNoman if you're using oauth2-client with Laravel 4, you will need to debug it to make it work. Here is how: thephpleague/oauth2-client#5

I will continue tomorrow...

@jnbdz
Copy link

jnbdz commented Jun 5, 2013

In the OAuth2-client Provider folder I added my own provider PHP script.

But every time I try to connect to my oauth-server I get an error.

So there seems to be a bug with the controller that I have created in the oauth-server side... Or there is something else bugging.

@jnbdz
Copy link

jnbdz commented Jun 6, 2013

It seems that there is another problem with the tutorial. Again I am not sure.

But in section "Create your first client" of the wiki it says to put data in "oauth_clients" db table.

I found that it did not work. So I did some digging and found that I had too add the client_id and redirect_uri to the "oauth_client_endpoints" db table.

It's weird because the way it is written in the wiki it seems it's just optional.

I am now getting this error: "The requested scope is invalid, unknown, or malformed. Check the "offline_access,email,read_stream" scope."

I will try to solve it tonight but no guarantees.

@alexbilbie
Copy link
Contributor

Regarding the scope error you should delimite your scopes with a space not a comma unless you override it.

Emailing from my iPhone like a BOSS

On 6 Jun 2013, at 07:59, Jean-Nicolas Boulay notifications@github.com wrote:

It seems that there is another problem with the tutorial. Again I am not sure.

But in section "Create your first client" of the wiki it says to put data in "oauth_clients" db table.

I found that it did not work. So I did some digging and found that I had too add the client_id and redirect_uri to the "oauth_client_endpoints" db table.

It's weird because the way it is written in the wiki it seems it's just optional.

I am now getting this error: "The requested scope is invalid, unknown, or malformed. Check the "offline_access,email,read_stream" scope."

I will try to solve it tonight but no guarantees.


Reply to this email directly or view it on GitHub.

@jnbdz
Copy link

jnbdz commented Jun 8, 2013

It works.

@quasiperfect
Copy link

@esolitos can you be so kind and tell me how you got it to work with CodeIgniter ?

@esolitos
Copy link

Hi QuasiPerfect, right now I don't remember the steps, anyway you have to change a looooot of things.
Take the tutorial as a pseudo-code and think what he's doing. After that you should be able to rewrite the tutorial code as you need it, imho don't try to copy-paste: Start over, it's easier.
If you still have issues I'll give a look to my code.

@alexbilbie
Copy link
Contributor

I'm closing this because there are going to be some updated docs in the wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants