[ 'authorize', 'initialize' ], 'public' => [] ]; protected static $log_mysql = 'all'; protected static $cache = false; protected static $cache_for = null; /** * If the original API call fails, the patreon token is updated outside of * the current transaction to ensure it doesn't get rolled back due to an * exception. * * The problem with that is that all subsequent API calls need this * value...so it's stored here statically on the class and used instead of * the old database value. */ protected static $patreon_token = null; /** * Redirect to Patreon to do the oAuth. Note: Put a space between scopes and * urlencode the whole thing if it includes special characters. */ public function authorize() { header('Location: https://www.patreon.com/oauth2/authorize?response_type=code&client_id=' . $this->setting->get('patreon_client_id') . '&redirect_uri=' . $this->setting->get('patreon_redirect_uri') . '&scope=identity'); } /** * Obtain the first set of tokens for a a patreon user, then sync that * user's Patreon settings, then return code that closes the window. * * @param string $code The code used to get tokens from patreon with. */ public function initialize($code = null) { if($code !== null) { $this->api('patreon_token', 'obtain', ['code' => $code]); $this->api('user', 'sync_patreon_status'); } echo '