blob: b172763f3dbf0c1d44a3468dc86a5754ba845353 (
plain)
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
|
---
title: "Tips and Tricks"
description: "Some tips and best practises for using MAL2Go (optional)"
weight: 4
---
These are some tips and best practises, and other notes for using MAL2Go. Following this is optional but might make your life easier!
## Better ways to store/read auth tokens:
- Use [godotenv](https://github.com/joho/godotenv) to read the auth token from a config file
- [Viper](https://github.com/spf13/viper) can do the same thing, but can also write to the file easily; also with viper you can locate the file anywhere on your system
- [go-keyring](https://github.com/zalando/go-keyring) can be used to read/write the secret token to the system's keyring. It is by far the most secure way but only works on some systems (windows, macos and linux with gnome-keyring)
## SearchManga and SearchAnime functions are quirky!
While you *can* specify fields to these functions, in order to get specific data, searching for some reason only returns limited fields most of the times.
It's not like it just doesn't support all of the fields but many times it just.. doesn't. So if you want to search *and* get ALL fields about an anime, or just
be sure that the data is complete, use [`SearchAnime`](/docs/mal2go/v4/anime/search-for-an-anime/)/[`SearchManga`](/docs/mal2go/v4/manga/search-for-a-manga/)
just to get the ID. After that, use [`GetAnimeById`](/docs/mal2go/v4/anime/get-anime-by-id/)/[`GetMangaById`](/docs/mal2go/v4/manga/get-manga-by-id/).
## macli has a good example on how to generate your own tokens with go
MAL2Go was made for my other project, [macli](https://github.com/MikunoNaka/macli).
Macli's `auth` package uses [`github.com/zalando/go-keyring`](https://github.com/zalando/go-keyring)
and the `net/http` package to prompt the user and generate an auth token with the given client id.
You can look at [the code](https://github.com/MikunoNaka/macli/tree/master/auth) to see how it works.
|