Making WordPress.org

Changeset 9223


Ignore:
Timestamp:
10/22/2019 06:08:56 AM (5 years ago)
Author:
dd32
Message:

Official WordPress Events: Tweak the logic around token refreshing.

The cron tasks were failing sporadically as the token wasn't valid - it looks like the token "looked valid" and expired, but looks like the refresh token was also expired.

This feels lik a hammer, forcing a new token to be fetched when both the token and refresh token are expired, but it worked.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/official-wordpress-events/meetup/class-meetup-oauth2-client.php

    r9107 r9223  
    295295            $needs_caching = true;
    296296        } elseif ( $this->is_expired_token( $token ) ) {
    297             $server_token  = $this->request_token( 'refresh_token', $token ); // Alternate for Steps 1 & 2.
     297            $server_token = $this->request_token( 'refresh_token', $token ); // Alternate for Steps 1 & 2.
     298
     299            // If the token is no longer valid but "looked valid" fetch a fresh one.
     300            if ( ! $server_token && $this->error->get_error_message( 'oauth_error' ) ) {
     301                $this->error->remove( 'oauth_error' );
     302
     303                // The token isn't valid for refreshing, request a new one.
     304                $authorization = $this->request_authorization_code(); // Step 1.
     305                $server_token  = $this->request_token( 'server_token', $authorization ); // Step 2.
     306            }
     307
    298308            $token         = $this->request_token( 'oauth_token', $server_token ); // Step 3.
    299309            $needs_caching = true;
Note: See TracChangeset for help on using the changeset viewer.