I did it totally wrong...
This commit is contained in:
parent
b3c82ecab6
commit
a48bd257f8
|
@ -72,7 +72,7 @@ func main() {
|
|||
formData.Set("code_verifier", localStorage.Call("getItem", "OAUTH-verifier").String())
|
||||
|
||||
// Create the request
|
||||
requestUri, err := url.JoinPath(js.Global().Get("window").Get("location").Get("origin").String(), js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String()+"/token")
|
||||
requestUri, err := url.JoinPath(js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String(), "/oauth/token")
|
||||
if err != nil {
|
||||
statusBox.Set("innerText", "Error joining URL: "+err.Error())
|
||||
tryAgain.Set("style", "")
|
||||
|
@ -104,7 +104,7 @@ func main() {
|
|||
|
||||
if response.StatusCode == 200 {
|
||||
// Fetch userinfo
|
||||
requestUri, err := url.JoinPath(js.Global().Get("window").Get("location").Get("origin").String(), js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String()+"/userinfo")
|
||||
requestUri, err := url.JoinPath(js.Global().Get("document").Call("getElementById", "authorizationUri").Get("innerText").String(), "/oauth/userinfo")
|
||||
if err != nil {
|
||||
statusBox.Set("innerText", "Error joining URL: "+err.Error())
|
||||
tryAgain.Set("style", "")
|
||||
|
@ -192,7 +192,14 @@ func main() {
|
|||
localStorage.Call("setItem", "OAUTH-verifier", verifier)
|
||||
|
||||
// Redirect to the authorization page
|
||||
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")
|
||||
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")
|
||||
if err != nil {
|
||||
statusBox.Set("innerText", "Error joining URL: "+err.Error())
|
||||
tryAgain.Set("style", "")
|
||||
return
|
||||
}
|
||||
|
||||
js.Global().Get("window").Get("location").Call("replace", authorizeUri)
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
Loading…
Reference in New Issue