From 191699140973afdb206ea10e36972f457b2a6eaa Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 15 Jun 2022 12:59:42 +0530 Subject: added authentication with system's keyring --- mal/mal.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'mal') diff --git a/mal/mal.go b/mal/mal.go index c693f40..b961bfd 100644 --- a/mal/mal.go +++ b/mal/mal.go @@ -19,9 +19,7 @@ along with this program. If not, see . package mal import ( - _ "github.com/joho/godotenv/autoload" - "os" - + "github.com/MikunoNaka/macli/auth" a "github.com/MikunoNaka/MAL2Go/anime" m "github.com/MikunoNaka/MAL2Go/manga" ua "github.com/MikunoNaka/MAL2Go/user/anime" @@ -33,13 +31,12 @@ var mangaClient m.Client var userAnimeClient ua.Client var userMangaClient um.Client -func init() { - // TODO: don't load access token from .env - var accessToken = os.Getenv("ACCESS_TOKEN") +func Init() { + secret := auth.GetToken() // initialise MAL2Go Client(s) - animeClient.AuthToken = "Bearer " + accessToken - mangaClient.AuthToken = "Bearer " + accessToken - userAnimeClient.AuthToken = "Bearer " + accessToken - userMangaClient.AuthToken = "Bearer " + accessToken + animeClient.AuthToken = "Bearer " + secret + mangaClient.AuthToken = "Bearer " + secret + userAnimeClient.AuthToken = "Bearer " + secret + userMangaClient.AuthToken = "Bearer " + secret } -- cgit v1.2.3