Increased API post timeout to 30 seconds

Simplified access token logic
This commit is contained in:
Justin Foell
2018-03-29 08:49:40 -05:00
parent e2a5ccae6d
commit 5797d2b639
4 changed files with 14 additions and 22 deletions
+11 -21
View File
@@ -298,29 +298,19 @@ class WPStrava_Settings {
$strava_info = $api->post( 'oauth/token', $data );
if ( $strava_info ) {
if ( ! empty( $strava_info->access_token ) ) {
$this->feedback .= __( 'Successfully authenticated.', 'wp-strava' );
return $strava_info->access_token;
} else {
if ( WP_STRAVA_DEBUG ) {
// Translators: message shown when there's an authentication problem with the Strava API (debug on).
$this->feedback .= sprintf( __( 'Authentication failed, OAuth response: <pre>%s</pre>', 'wp-strava' ), print_r( $strava_info, true ) ); // phpcs:ignore -- Debug output.
} else {
// Translators: message shown when there's an authentication problem with the Strava API.
$this->feedback .= __( 'Authentication failed, please check your credentials. See full error by adding<br/><code>define( \'WP_STRAVA_DEBUG\', true );</code><br/>to wp-config.php', 'wp-strava' );
}
return false;
}
} else {
// Translators: error message from Strava
$this->feedback .= sprintf( __( 'There was an error receiving data from Strava: %s', 'wp-strava' ), print_r( $strava_info, true ) ); // phpcs:ignore -- Debug output.
return false;
if ( isset( $strava_info->access_token ) ) {
$this->feedback .= __( 'Successfully authenticated.', 'wp-strava' );
return $strava_info->access_token;
}
} else {
$this->feedback .= __( 'Missing Client ID or Client Secret.', 'wp-strava' );
// Translators: error message from Strava
$this->feedback .= sprintf( __( 'There was an error receiving data from Strava: <pre>%s</pre>', 'wp-strava' ), print_r( $strava_info, true ) ); // phpcs:ignore -- Debug output.
return false;
} // End if.
}
$this->feedback .= __( 'Missing Client ID or Client Secret.', 'wp-strava' );
return false;
}
public function print_gmaps_key_input() {