diff --git a/main.go b/main.go
index 85dac31906a0f06b46182d6d7e894bd17ab7dfd7..8cce8c928e7e5f11294320d6b1a06830d8e93504 100644
--- a/main.go
+++ b/main.go
@@ -430,7 +430,7 @@ func main() {
 				http.Error(w, http.StatusText(500), 500)
 			}
 			clientSecretStartIndex += len(clientSecretKey)
-			clientSecret = pageContent[clientSecretStartIndex : clientSecretStartIndex+clientSecretStartIndex]
+			clientSecret = pageContent[clientSecretStartIndex : clientSecretStartIndex+clientSecretLength]
 			//Check for code
 			codeKey := "code="
 			codeLength := 27
@@ -443,7 +443,6 @@ func main() {
 			}
 			//Check for grant_type
 			grandTypeKey := "grant_type="
-			grandTypeLength := 27
 			grandTypeStartIndex := strings.Index(pageContent, grandTypeKey)
 			if grandTypeStartIndex == -1 {
 				log.Error("No grant_type found")