@@ -140,8 +140,8 @@ public function get_parameters( $require_token = true, $extra = array() ) {
140
140
if ( ! empty ( $ errors ) ) {
141
141
$ message = sprintf (
142
142
_n (
143
- 'Missing OAuth parameter %s ' ,
144
- 'Missing OAuth parameters %s ' ,
143
+ __ ( 'Missing OAuth parameter %s ' , ' rest_oauth1 ' ) ,
144
+ __ ( 'Missing OAuth parameters %s ' , ' rest_oauth1 ' ) ,
145
145
count ( $ errors )
146
146
),
147
147
implode (', ' , $ errors )
@@ -252,7 +252,7 @@ public function dispatch( $route ) {
252
252
return $ params ;
253
253
}
254
254
if ( empty ( $ params ) ) {
255
- return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' ), array ( 'status ' => 400 ) );
255
+ return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
256
256
}
257
257
258
258
return $ this ->generate_request_token ( $ params );
@@ -264,7 +264,7 @@ public function dispatch( $route ) {
264
264
return $ params ;
265
265
}
266
266
if ( empty ( $ params ) ) {
267
- return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' ), array ( 'status ' => 400 ) );
267
+ return new WP_Error ( 'json_oauth1_missing_parameter ' , __ ( 'No OAuth parameters supplied ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
268
268
}
269
269
270
270
return $ this ->generate_access_token (
@@ -274,7 +274,7 @@ public function dispatch( $route ) {
274
274
);
275
275
276
276
default :
277
- return new WP_Error ( 'json_oauth1_invalid_route ' , __ ( 'Route is invalid ' ), array ( 'status ' => 404 ) );
277
+ return new WP_Error ( 'json_oauth1_invalid_route ' , __ ( 'Route is invalid ' , ' rest_oauth1 ' ), array ( 'status ' => 404 ) );
278
278
}
279
279
}
280
280
@@ -295,7 +295,7 @@ public function check_token( $token, $consumer_key ) {
295
295
}
296
296
297
297
if ( ! hash_equals ( (string ) $ token ['consumer ' ], (string ) $ consumer ->ID ) ) {
298
- return new WP_Error ( 'json_oauth1_consumer_mismatch ' , __ ( 'Token is not registered for the given consumer ' ), array ( 'status ' => 401 ) );
298
+ return new WP_Error ( 'json_oauth1_consumer_mismatch ' , __ ( 'Token is not registered for the given consumer ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
299
299
}
300
300
301
301
return array ( $ consumer , new WP_User ( $ token ['user ' ] ) );
@@ -311,13 +311,13 @@ public function get_request_token( $key ) {
311
311
$ data = get_option ( 'oauth1_request_ ' . $ key , null );
312
312
313
313
if ( empty ( $ data ) ) {
314
- return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Invalid token ' ), array ( 'status ' => 400 ) );
314
+ return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Invalid token ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
315
315
}
316
316
317
317
// Check expiration
318
318
if ( $ data ['expiration ' ] < time () ) {
319
319
$ this ->remove_request_token ( $ key );
320
- return new WP_Error ( 'json_oauth1_expired_token ' , __ ( 'OAuth request token has expired ' ), array ( 'status ' => 401 ) );
320
+ return new WP_Error ( 'json_oauth1_expired_token ' , __ ( 'OAuth request token has expired ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
321
321
}
322
322
323
323
return $ data ;
@@ -378,7 +378,7 @@ public function set_request_token_callback( $key, $callback ) {
378
378
379
379
$ consumer = $ token ['consumer ' ];
380
380
if ( ! $ this ->check_callback ( $ callback , $ consumer ) ) {
381
- return new WP_Error ( 'json_oauth1_invalid_callback ' , __ ( 'Callback URL is invalid ' ) );
381
+ return new WP_Error ( 'json_oauth1_invalid_callback ' , __ ( 'Callback URL is invalid ' , ' rest_oauth1 ' ) );
382
382
}
383
383
384
384
$ token ['callback ' ] = $ callback ;
@@ -504,7 +504,7 @@ public function authorize_request_token( $key, $user = null ) {
504
504
}
505
505
506
506
if ( empty ( $ user ) ) {
507
- return new WP_Error ( 'json_oauth1_invalid_user ' , __ ( 'Invalid user specified for access token ' ) );
507
+ return new WP_Error ( 'json_oauth1_invalid_user ' , __ ( 'Invalid user specified for access token ' , ' rest_oauth1 ' ) );
508
508
}
509
509
510
510
$ token ['authorized ' ] = true ;
@@ -554,11 +554,11 @@ public function generate_access_token( $oauth_consumer_key, $oauth_token, $oauth
554
554
555
555
// Check verification
556
556
if ( $ token ['authorized ' ] !== true ) {
557
- return new WP_Error ( 'json_oauth1_unauthorized_token ' , __ ( 'OAuth token has not been authorized ' ), array ( 'status ' => 401 ) );
557
+ return new WP_Error ( 'json_oauth1_unauthorized_token ' , __ ( 'OAuth token has not been authorized ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
558
558
}
559
559
560
560
if ( $ oauth_verifier !== $ token ['verifier ' ] ) {
561
- return new WP_Error ( 'json_oauth1_invalid_verifier ' , __ ( 'OAuth verifier does not match ' ), array ( 'status ' => 400 ) );
561
+ return new WP_Error ( 'json_oauth1_invalid_verifier ' , __ ( 'OAuth verifier does not match ' , ' rest_oauth1 ' ), array ( 'status ' => 400 ) );
562
562
}
563
563
564
564
$ this ->should_attempt = false ;
@@ -600,7 +600,7 @@ public function generate_access_token( $oauth_consumer_key, $oauth_token, $oauth
600
600
public function revoke_access_token ( $ key ) {
601
601
$ data = $ this ->get_access_token ( $ key );
602
602
if ( empty ( $ data ) ) {
603
- return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Access token does not exist ' ), array ( 'status ' => 401 ) );
603
+ return new WP_Error ( 'json_oauth1_invalid_token ' , __ ( 'Access token does not exist ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
604
604
}
605
605
606
606
delete_option ( 'oauth1_access_ ' . $ key );
@@ -652,7 +652,7 @@ protected function check_oauth_signature( $consumer, $oauth_params, $token = nul
652
652
653
653
// sort parameters
654
654
if ( ! uksort ( $ params , 'strcmp ' ) )
655
- return new WP_Error ( 'json_oauth1_failed_parameter_sort ' , __ ( 'Invalid Signature - failed to sort parameters ' ), array ( 'status ' => 401 ) );
655
+ return new WP_Error ( 'json_oauth1_failed_parameter_sort ' , __ ( 'Invalid Signature - failed to sort parameters ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
656
656
657
657
$ query_string = $ this ->create_signature_string ( $ params );
658
658
@@ -674,13 +674,13 @@ protected function check_oauth_signature( $consumer, $oauth_params, $token = nul
674
674
break ;
675
675
676
676
default :
677
- return new WP_Error ( 'json_oauth1_invalid_signature_method ' , __ ( 'Signature method is invalid ' ), array ( 'status ' => 401 ) );
677
+ return new WP_Error ( 'json_oauth1_invalid_signature_method ' , __ ( 'Signature method is invalid ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
678
678
}
679
679
680
680
$ signature = base64_encode ( hash_hmac ( $ hash_algorithm , $ string_to_sign , $ key , true ) );
681
681
682
682
if ( ! hash_equals ( $ signature , $ consumer_signature ) ) {
683
- return new WP_Error ( 'json_oauth1_signature_mismatch ' , __ ( 'OAuth signature does not match ' ), array ( 'status ' => 401 ) );
683
+ return new WP_Error ( 'json_oauth1_signature_mismatch ' , __ ( 'OAuth signature does not match ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
684
684
}
685
685
686
686
return true ;
@@ -751,15 +751,15 @@ protected function check_oauth_timestamp_and_nonce( $consumer, $timestamp, $nonc
751
751
$ valid_window = apply_filters ( 'json_oauth1_timestamp_window ' , 15 * MINUTE_IN_SECONDS );
752
752
753
753
if ( ( $ timestamp < time () - $ valid_window ) || ( $ timestamp > time () + $ valid_window ) )
754
- return new WP_Error ( 'json_oauth1_invalid_timestamp ' , __ ( 'Invalid timestamp ' ), array ( 'status ' => 401 ) );
754
+ return new WP_Error ( 'json_oauth1_invalid_timestamp ' , __ ( 'Invalid timestamp ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
755
755
756
756
$ used_nonces = $ consumer ->nonces ;
757
757
758
758
if ( empty ( $ used_nonces ) )
759
759
$ used_nonces = array ();
760
760
761
761
if ( in_array ( $ nonce , $ used_nonces ) )
762
- return new WP_Error ( 'json_oauth1_nonce_already_used ' , __ ( 'Invalid nonce - nonce has already been used ' ), array ( 'status ' => 401 ) );
762
+ return new WP_Error ( 'json_oauth1_nonce_already_used ' , __ ( 'Invalid nonce - nonce has already been used ' , ' rest_oauth1 ' ), array ( 'status ' => 401 ) );
763
763
764
764
$ used_nonces [ $ timestamp ] = $ nonce ;
765
765
0 commit comments