/** * Fetch Flowplayer Drive API authentication code * * @since 1.2.0 */ protected function make_auth_request() { // get the login info $options = fp5_get_settings(); $user_name = isset($options['user_name']) ? $options['user_name'] : ''; $password = isset($options['password']) ? $options['password'] : ''; if (!$user_name || !$password) { Flowplayer_Drive_Error::showLoginError(); return; } $seed = $this->make_auth_seed_request(); if (!$seed) { return; } $auth_api_url = add_query_arg(array('callback' => '?', 'username' => $user_name, 'hash' => sha1($user_name . $seed . $password), 'seed' => $seed), $this->account_api_url); $args = array('user-agent' => 'wp_flowplayer5/version_' . $this->plugin_version); $response = wp_remote_get(esc_url_raw($auth_api_url), $args); if (200 != wp_remote_retrieve_response_code($response)) { Flowplayer_Drive_Error::showAuthenticationApiError(); return; } $auth = $this->json_decode_body($response); if (!$auth->success) { Flowplayer_Drive_Error::showUsernamePasswordError(); return; } return $auth->result->authcode; }