From 6bb6d4486de0219eeb27e265fc65ae372abd10b5 Mon Sep 17 00:00:00 2001
From: Hugo <hnouts@grandlyon.com>
Date: Thu, 8 Oct 2020 17:12:56 +0200
Subject: [PATCH] scope causes 400

---
 main.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go
index be22178..6d77f9c 100644
--- a/main.go
+++ b/main.go
@@ -453,18 +453,21 @@ func main() {
 		data.Set("grant_type", grantType)
 		data.Set("redirect_uri", redirectUri)
 		if grantType == "authorization_code" {
+			log.Info("grantType is authorization code")
 			data.Set("code", code)
-		} else {
+		} else if grantType == "client_credentials" {
+			log.Info("grantType is client_credentials")
 			data.Set("scope", scope)
 		}
 
+		log.Debug("data sent is : ", data)
 		log.Debug("Send request to token endpoint: ", tokenUrl)
 		http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
 		response, err := http.PostForm(tokenUrl, data)
 		if err != nil {
 			log.Error(err)
 		} else {
-			log.Debug("Endpoint response with status", response.Status)
+			log.Debug("Endpoint response with status", response.Status, response)
 			defer response.Body.Close()
 			if response.StatusCode >= 200 && response.StatusCode <= 299 {
 				// Set Content-Type in response header
-- 
GitLab