Making WordPress.org


Ignore:
Timestamp:
04/01/2022 03:30:53 AM (3 years ago)
Author:
dd32
Message:

Plugin Directory: Stats Report: Fix the first request to the HelpScout API endpoints.

  • The first non-cached request to the HelpScout API failed to use the proper Authorization header format, due to a missing BEARER prefix.
  • Increased the API timeout for HelpScout to 15s, although it probably doesn't need it.
  • Make it more obvious that something is wrong with the HelpScout details, by returning 0's for all numbers, rather than just one or two of them.

See #4306.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/clients/class-helpscout.php

    r11726 r11728  
    99class HelpScout {
    1010    const API_BASE = 'https://api.helpscout.net';
     11
     12    /**
     13     * The HTTP timeout for the HelpScout API.
     14     */
     15    const TIMEOUT = 15;
    1116
    1217    public static function api( $url, $args = null, $method = 'GET' ) {
     
    3338                    'Authorization' => self::get_auth_string(),
    3439                ],
     40                'timeout' => self::TIMEOUT,
    3541                'body'    => ( 'POST' === $method && $args ) ? $args : null,
    3642            )
     
    5258            self::API_BASE . '/v2/oauth2/token',
    5359            array(
    54                 'body' => array(
     60                'timeout' => self::TIMEOUT,
     61                'body'    => array(
    5562                    'grant_type'    => 'client_credentials',
    5663                    'client_id'     => HELPSCOUT_APP_ID,
     
    7279        set_site_transient( __CLASS__ . 'get_auth_token', [ 'exp' => time() + $expiry, 'token' => $token ], $expiry );
    7380
    74         return $token;
     81        return 'BEARER ' . $token;
    7582    }
    7683
Note: See TracChangeset for help on using the changeset viewer.