I did it totally wrong, yet again.

Touche, me
This commit is contained in:
Tracker-Friendly 2024-10-15 19:34:53 +01:00
parent a48bd257f8
commit b0d5b191ce
1 changed files with 3 additions and 10 deletions

View File

@ -72,7 +72,7 @@ func main() {
formData.Set("code_verifier", localStorage.Call("getItem", "OAUTH-verifier").String()) formData.Set("code_verifier", localStorage.Call("getItem", "OAUTH-verifier").String())
// Create the request // Create the request
requestUri, err := url.JoinPath(js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String(), "/oauth/token") requestUri, err := url.JoinPath(js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String(), "/api/oauth/token")
if err != nil { if err != nil {
statusBox.Set("innerText", "Error joining URL: "+err.Error()) statusBox.Set("innerText", "Error joining URL: "+err.Error())
tryAgain.Set("style", "") tryAgain.Set("style", "")
@ -104,7 +104,7 @@ func main() {
if response.StatusCode == 200 { if response.StatusCode == 200 {
// Fetch userinfo // Fetch userinfo
requestUri, err := url.JoinPath(js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String(), "/oauth/userinfo") requestUri, err := url.JoinPath(js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String(), "/api/oauth/userinfo")
if err != nil { if err != nil {
statusBox.Set("innerText", "Error joining URL: "+err.Error()) statusBox.Set("innerText", "Error joining URL: "+err.Error())
tryAgain.Set("style", "") tryAgain.Set("style", "")
@ -192,14 +192,7 @@ func main() {
localStorage.Call("setItem", "OAUTH-verifier", verifier) localStorage.Call("setItem", "OAUTH-verifier", verifier)
// Redirect to the authorization page // Redirect to the authorization page
authorizeUri, err := url.JoinPath(js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String(), "/authorize?response_type=code&client_id="+js.Global().Get("document").Call("getElementById", "clientId").Get("innerText").String()+"&redirect_uri="+url.QueryEscape(js.Global().Get("window").Get("location").Get("origin").String()+"/oauth")+"&code_challenge="+verifierChallenge+"&code_challenge_method=S256") js.Global().Get("window").Get("location").Call("replace", js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String()+"/authorize?response_type=code&client_id="+js.Global().Get("document").Call("getElementById", "clientId").Get("innerText").String()+"&redirect_uri="+url.QueryEscape(js.Global().Get("window").Get("location").Get("origin").String()+"/oauth")+"&code_challenge="+verifierChallenge+"&code_challenge_method=S256")
if err != nil {
statusBox.Set("innerText", "Error joining URL: "+err.Error())
tryAgain.Set("style", "")
return
}
js.Global().Get("window").Get("location").Call("replace", authorizeUri)
} }
}() }()