Skip to content

Commit be91856

Browse files
committed
Generate a verification code when authorizing
1 parent 38c1a9c commit be91856

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/class-wp-json-authentication-oauth1.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class WP_JSON_Authentication_OAuth1 extends WP_JSON_Authentication {
1111
const CONSUMER_SECRET_LENGTH = 48;
1212
const TOKEN_KEY_LENGTH = 24;
1313
const TOKEN_SECRET_LENGTH = 48;
14+
const VERIFIER_LENGTH = 24;
1415

1516
/**
1617
* Authentication type
@@ -319,7 +320,7 @@ public function generate_request_token( $params ) {
319320
*
320321
* Enables the request token to be used to generate an access token
321322
* @param string $key Token ID
322-
* @return bool|WP_Error True on success, error otherwise
323+
* @return string|WP_Error Verification code on success, error otherwise
323324
*/
324325
public function authorize_request_token( $key ) {
325326
$token = $this->get_request_token( $key );
@@ -328,9 +329,10 @@ public function authorize_request_token( $key ) {
328329
}
329330

330331
$token['authorized'] = true;
332+
$token['verifier'] = wp_generate_password( self::VERIFIER_LENGTH, false );
331333
$token = apply_filters( 'oauth_request_token_authorized_data', $token );
332334
update_option( 'oauth1_request_' . $key, $token );
333-
return true;
335+
return $token['verifier'];
334336
}
335337

336338
/**

0 commit comments

Comments
 (0)