/**
  * Exchange an authorization code for an access token.
  *
  * @param string $tokenendpoint The token endpoint URI.
  * @param string $code An authorization code.
  * @return array Received parameters.
  */
 public function tokenrequest($code)
 {
     if (empty($this->endpoints['token'])) {
         throw new \moodle_exception('erroroidcclientnotokenendpoint', 'auth_oidc');
     }
     $params = ['client_id' => $this->clientid, 'client_secret' => $this->clientsecret, 'grant_type' => 'authorization_code', 'code' => $code, 'redirect_uri' => $this->redirecturi];
     $returned = $this->httpclient->post($this->endpoints['token'], $params);
     return \auth_oidc\utils::process_json_response($returned, ['id_token' => null]);
 }