From 9b66241ae1276bb0f07e1d2e06d16309a35951e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Dagef=C3=B6rde?=
 <jan.dagefoerde@ercis.uni-muenster.de>
Date: Wed, 12 Jul 2017 16:51:16 +0200
Subject: [PATCH] bad patch -- use basic auth together with payload-based
 auth... maybe a bad idea

---
 lib/oauthlib.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/oauthlib.php b/lib/oauthlib.php
index 8f3e795795..5b0231e8f6 100644
--- a/lib/oauthlib.php
+++ b/lib/oauthlib.php
@@ -544,12 +544,16 @@ abstract class oauth2_client extends curl {
             'redirect_uri' => $callbackurl->out(false),
         );
 
+        $headersbefore = $this->header;
+        $this->header[] = "Authorization: Basic " . base64_encode("{$this->clientid}:{$this->clientsecret}");
+
         // Requests can either use http GET or POST.
         if ($this->use_http_get()) {
             $response = $this->get($this->token_url(), $params);
         } else {
             $response = $this->post($this->token_url(), $this->build_post_data($params));
         }
+        $this->header = $headersbefore;
 
         if ($this->info['http_code'] !== 200) {
             throw new moodle_exception('Could not upgrade oauth token');
-- 
2.13.0

