forked from xqdoo00o/OpenAIAuth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
33 lines (30 loc) · 760 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
import (
"encoding/json"
"fmt"
"os"
"github.com/yhhit/OpenAIAuth/auth"
)
func main() {
auth := auth.NewAuthenticator(os.Getenv("OPENAI_EMAIL"), os.Getenv("OPENAI_PASSWORD"), os.Getenv("PROXY"))
err := auth.Begin()
if err != nil {
println("Error: " + err.Details)
println("Location: " + err.Location)
println("Status code: " + fmt.Sprint(err.StatusCode))
return
}
// if os.Getenv("PROXY") != "" {
_, err = auth.GetPUID()
if err != nil {
println("Error: " + err.Details)
println("Location: " + err.Location)
println("Status code: " + fmt.Sprint(err.StatusCode))
return
}
// }
// JSON encode auth.GetAuthResult()
result := auth.GetAuthResult()
result_json, _ := json.Marshal(result)
println(string(result_json))
}