aboutsummaryrefslogtreecommitdiff
path: root/mal
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-15 12:59:42 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-15 12:59:42 +0530
commit191699140973afdb206ea10e36972f457b2a6eaa (patch)
treeb9bad36e91cf22358c89316a61679d9b2665e457 /mal
parentab3db8a4ca89293ce0928177e8845d622f13755f (diff)
added authentication with system's keyring
Diffstat (limited to 'mal')
-rw-r--r--mal/mal.go17
1 files changed, 7 insertions, 10 deletions
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 <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
}