WordPress.org

Making WordPress.org


Ignore:
Timestamp:
08/17/2019 12:35:04 AM (8 months ago)
Author:
coreymckrill
Message:

Official WordPress Events: Tweak Meetup client to try to avoid auth token probs

This attempts to avoid the scenario where the client has somehow stored an
oauth token that is expired/invalid, and keeps using it for requests anyway.
Now it will try to detect when the token it has isn't working and refresh it
without breaking the current request cycle.

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

    r9105 r9107  
    9797            ),
    9898        ) );
     99
     100        // Pre-cache the oauth token.
     101        $this->get_oauth_token();
    99102    }
    100103
     
    308311
    309312        return $oauth_token;
     313    }
     314
     315    /**
     316     * Un-cache any existing oauth token and request a new one.
     317     *
     318     * This also resets the error property so that it has a clean slate when it attempts to request a new token.
     319     *
     320     * Useful if a token stops working during a batch of requests :/
     321     *
     322     * @return void
     323     */
     324    public function reset_oauth_token() {
     325        delete_site_option( self::SITE_OPTION_KEY_OAUTH );
     326
     327        $this->oauth_token = array();
     328        $this->error       = new WP_Error();
     329
     330        $this->get_oauth_token();
    310331    }
    311332
Note: See TracChangeset for help on using the changeset viewer.