array( 'grant_type' => 'authorization_code', 'code' => $_GET['code'], 'redirect_uri' => $redirect_uri, 'client_id' => $client_id, 'client_secret' => $client_secret ) )); if (is_wp_error($response)) return; $data = json_decode(wp_remote_retrieve_body($response), true); if (isset($data['access_token'])) { update_option('sro_access_token', $data['access_token']); update_option('sro_refresh_token', $data['refresh_token']); update_option('sro_token_expires', time() + 3500); } wp_redirect(admin_url('options-general.php?page=sro')); exit; } add_action('admin_init', 'sro_handle_oauth');