bshaffer / oauth2-server-php

A library for implementing an OAuth2 Server in php
http://bshaffer.github.io/oauth2-server-php-docs
MIT License
3.26k stars 951 forks source link

Question on how to associate tokens with local user ? #653

Open EugeneLiang opened 9 years ago

EugeneLiang commented 9 years ago

Hi good day, I have a question regarding: http://bshaffer.github.io/oauth2-server-php-docs/overview/userid/

After going through the walkthrough on http://bshaffer.github.io/oauth2-server-php-docs/cookbook/, I have managed to successful complete all the steps, except for associating local users with access tokens.

Q1) After the token is successfully returned for step "Create an Authorize Controller", how do i pass the array into handleAuthorizeRequest method found in http://bshaffer.github.io/oauth2-server-php-docs/overview/userid/ ?

Q2) Can the technique shown in http://bshaffer.github.io/oauth2-server-php-docs/overview/userid/ be adapted to use my own user table ? I am trying to implement my own Oauth server on a wordpress installation; on WordPress, there's a user table already. How would this be done ?

Thank you and cheers.

bshaffer commented 9 years ago

Hell Eugene! Thanks for your question!

The fourth argument to handleAuthorizationRequest should be your scalar $user_id, which I imagine will be in the array somewhere.

As for the wordpress UserStorage adapter, there is a Wordpress plugin which uses a version of this library, and uses an OAuth2\Storage\Wordpressdb class that may be what you're looking for.

EugeneLiang commented 9 years ago

Hi there, thanks for the speedy reply! Much appreciated.

Another not so smart question following your answer: what about the first 3 argument of handleAuthorizationRequest ? Do they have to be strictly Oauth objects? ( I'm a php noob )

Cheers!

On Tue, 13 Oct 2015 at 08:42 Brent Shaffer notifications@github.com wrote:

Hell Eugene! Thanks for your question!

The fourth argument to handleAuthorizationRequest should be your $user_id, which I imagine will be in the array somewhere.

As for the wordpress UserStorage adapter, there is a Wordpress plugin https://wordpress.org/plugins/oauth2-provider/ which uses a version of this library, and uses an OAuth2\Storage\Wordpressdb https://github.com/justingreerbbi/wordpress-oauth-server/blob/master/library/OAuth2/Storage/Wordpressdb.php class that may be what you're looking for.

— Reply to this email directly or view it on GitHub https://github.com/bshaffer/oauth2-server-php/issues/653#issuecomment-147558928 .