From 7b841abf2fc0ed0522c1985face762ca60c69b83 Mon Sep 17 00:00:00 2001 From: ekzyis Date: Sun, 16 Apr 2023 22:03:14 +0200 Subject: [PATCH] Fix SN API authorization --- .env.template | 2 +- sn.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.env.template b/.env.template index 123b52b..959dded 100644 --- a/.env.template +++ b/.env.template @@ -1 +1 @@ -NEXT_AUTH_CSRF_TOKEN= \ No newline at end of file +AUTH_COOKIE= \ No newline at end of file diff --git a/sn.go b/sn.go index a4bffb8..0f42094 100644 --- a/sn.go +++ b/sn.go @@ -41,8 +41,8 @@ type UpsertLinkResponse struct { } var ( - SnApiUrl string - SnApiToken string + SnApiUrl string + SnAuthCookie string ) func init() { @@ -51,10 +51,10 @@ func init() { if err != nil { log.Fatal("Error loading .env file") } - flag.StringVar(&SnApiToken, "NEXT_AUTH_CSRF_TOKEN", "", "Token required for authorizing requests to stacker.news/api/graphql") + flag.StringVar(&SnAuthCookie, "AUTH_COOKIE", "", "Cookie required for authorizing requests to stacker.news/api/graphql") flag.Parse() - if SnApiToken == "" { - log.Fatal("NEXT_AUTH_CSRF_TOKEN not set") + if SnAuthCookie == "" { + log.Fatal("AUTH_COOKIE not set") } } @@ -69,7 +69,7 @@ func MakeStackerNewsRequest(body GraphQLPayload) *http.Response { panic(err) } req.Header.Set("Content-Type", "application/json") - req.Header.Set("Cookie", fmt.Sprintf("__Host-next-auth.csrf-token=%s", SnApiToken)) + req.Header.Set("Cookie", SnAuthCookie) client := http.DefaultClient resp, err := client.Do(req)