diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-15 12:59:42 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-15 12:59:42 +0530 |
commit | 191699140973afdb206ea10e36972f457b2a6eaa (patch) | |
tree | b9bad36e91cf22358c89316a61679d9b2665e457 /mal | |
parent | ab3db8a4ca89293ce0928177e8845d622f13755f (diff) |
added authentication with system's keyring
Diffstat (limited to 'mal')
-rw-r--r-- | mal/mal.go | 17 |
1 files changed, 7 insertions, 10 deletions
@@ -19,9 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. 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 } |