22
33namespace WP \OAuth2 \Types ;
44
5+ use WP_Http ;
56use WP_Error ;
67use WP \OAuth2 \Client ;
78
@@ -10,6 +11,7 @@ abstract class Base implements Type {
1011 * Handle authorisation page.
1112 */
1213 public function handle_authorisation () {
14+
1315 if ( empty ( $ _GET ['client_id ' ] ) ) {
1416 return new WP_Error (
1517 'oauth2.types.authorization_code.handle_authorisation.missing_client_id ' ,
@@ -23,7 +25,7 @@ public function handle_authorisation() {
2325 $ scope = isset ( $ _GET ['scope ' ] ) ? wp_unslash ( $ _GET ['scope ' ] ) : null ;
2426 $ state = isset ( $ _GET ['state ' ] ) ? wp_unslash ( $ _GET ['state ' ] ) : null ;
2527
26- $ client = Client::get_by_id ( $ client_id );
28+ $ client = Client::get_by_client_id ( $ client_id );
2729 if ( empty ( $ client ) ) {
2830 return new WP_Error (
2931 'oauth2.types.authorization_code.handle_authorisation.invalid_client_id ' ,
@@ -99,10 +101,10 @@ protected function validate_redirect_uri( Client $client, $redirect_uri = null )
99101 *
100102 * @param Client $client Client being authorised.
101103 */
102- protected function render_form ( Client $ client ) {
103- $ file = locate_template ( 'oauth1 -authorize.php ' );
104+ public function render_form ( Client $ client ) {
105+ $ file = locate_template ( 'oauth2 -authorize.php ' );
104106 if ( empty ( $ file ) ) {
105- $ file = dirname ( dirname ( __DIR__ ) ) . '/theme/oauth1 -authorize.php ' ;
107+ $ file = dirname ( dirname ( __DIR__ ) ) . '/theme/oauth2 -authorize.php ' ;
106108 }
107109
108110 include $ file ;
@@ -114,6 +116,7 @@ protected function render_form( Client $client ) {
114116 * @param Client $client Client to generate nonce for.
115117 */
116118 protected function get_nonce_action ( Client $ client ) {
117- return sprintf ( 'oauth2_authorize:%s ' , $ client ->get_key () );
119+ // return sprintf( 'oauth2_authorize:%s', $client->get_post_id() );
120+ return 'json_oauth2_authorize ' ;
118121 }
119122}
0 commit comments