using refresh token now
This commit is contained in:
parent
664741d3b2
commit
4154fdeec9
33
main.go
33
main.go
@ -140,16 +140,39 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
os.MkdirAll(filepath.Join(dir, "minecraft_test"), 0755)
|
|
||||||
f, _ := os.OpenFile(filepath.Join(dir, "minecraft_test", "authentication.json"), os.O_CREATE|os.O_RDWR, 0755)
|
|
||||||
defer f.Close()
|
|
||||||
data, _ = json.Marshal(auth.Access)
|
|
||||||
f.Write(data)
|
|
||||||
} else {
|
} else {
|
||||||
f, _ := os.OpenFile(filepath.Join(dir, "minecraft_test", "authentication.json"), os.O_CREATE|os.O_RDWR, 0755)
|
f, _ := os.OpenFile(filepath.Join(dir, "minecraft_test", "authentication.json"), os.O_CREATE|os.O_RDWR, 0755)
|
||||||
data, _ := io.ReadAll(f)
|
data, _ := io.ReadAll(f)
|
||||||
json.Unmarshal(data, &auth.Access)
|
json.Unmarshal(data, &auth.Access)
|
||||||
|
resp, err := http.PostForm("https://login.microsoftonline.com/consumers/oauth2/v2.0/token", url.Values{
|
||||||
|
"client_id": {client_id},
|
||||||
|
"grant_type": {"refresh_token"},
|
||||||
|
"refresh_token": {auth.Access.Refresh_token},
|
||||||
|
"scope": {"XboxLive.SignIn XboxLive.offline_access"},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Authentication Request Error: %s\n", err)
|
||||||
}
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
//if resp.StatusCode != 200 {
|
||||||
|
// fmt.Printf("Authentication Request Error: %s\n", resp.Status)
|
||||||
|
//}
|
||||||
|
data, _ = io.ReadAll(resp.Body)
|
||||||
|
authResp := authenticationResp{}
|
||||||
|
json.Unmarshal(data, &authResp)
|
||||||
|
if authResp.Error == "" {
|
||||||
|
fmt.Printf("Authenticated!\n")
|
||||||
|
auth.Access = authResp
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
os.MkdirAll(filepath.Join(dir, "minecraft_test"), 0755)
|
||||||
|
f, _ := os.OpenFile(filepath.Join(dir, "minecraft_test", "authentication.json"), os.O_CREATE|os.O_RDWR, 0755)
|
||||||
|
defer f.Close()
|
||||||
|
data, _ := json.Marshal(auth.Access)
|
||||||
|
f.Write(data)
|
||||||
|
|
||||||
req, _ := json.Marshal(xboxAuthRequest{Properties: xboxAuthProperties{AuthMethod: "RPS", SiteName: "user.auth.xboxlive.com", RpsTicket: "d=" + auth.Access.Access_token}, RelyingParty: "http://auth.xboxlive.com", TokenType: "JWT"})
|
req, _ := json.Marshal(xboxAuthRequest{Properties: xboxAuthProperties{AuthMethod: "RPS", SiteName: "user.auth.xboxlive.com", RpsTicket: "d=" + auth.Access.Access_token}, RelyingParty: "http://auth.xboxlive.com", TokenType: "JWT"})
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
httpReq, _ := http.NewRequest("POST", "https://user.auth.xboxlive.com/user/authenticate", bytes.NewBuffer(req))
|
httpReq, _ := http.NewRequest("POST", "https://user.auth.xboxlive.com/user/authenticate", bytes.NewBuffer(req))
|
||||||
|
Loading…
Reference in New Issue
Block a user