48 lines
935 B
Go
48 lines
935 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"crypto/ecdsa"
|
|
"crypto/elliptic"
|
|
"crypto/rand"
|
|
"fmt"
|
|
|
|
"github.com/sandertv/gophertunnel/minecraft/auth"
|
|
)
|
|
|
|
func main() {
|
|
fmt.Println("Requesting Oauth")
|
|
token, err := auth.RequestLiveToken()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
} else {
|
|
ts := auth.RefreshTokenSource(token)
|
|
fmt.Println("Generating Key")
|
|
key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
ctx := context.Background()
|
|
fmt.Println("Requesting XBL Token")
|
|
token, err = ts.Token()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
xbl, err := auth.RequestXBLToken(ctx, token, "rp://api.minecraftservices.com/")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println("Requesting Minecraft Chain")
|
|
ctx = context.Background()
|
|
_, err = auth.RequestMinecraftChain(ctx, xbl, key)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
}
|
|
}
|