switched from .env to built-in envrionment file

This commit is contained in:
2024-08-16 23:32:16 -04:00
parent f37622010f
commit 55cb0e2bd5
9 changed files with 37 additions and 33 deletions

View File

@ -8,7 +8,6 @@ import (
"io"
"log"
"net/http"
"os"
"sync"
"github.com/99designs/keyring"
@ -47,7 +46,7 @@ func (a *App) SimklLogin() {
accessToken, err := simklRing.Get("SimklAccessToken")
scope, err := simklRing.Get("SimklScope")
if err != nil || len(accessToken.Data) == 0 {
getSimklCodeUrl := "https://simkl.com/oauth/authorize?response_type=code&client_id=" + os.Getenv("SIMKL_CLIENT_ID") + "&redirect_uri=" + os.Getenv("SIMKL_CALLBACK_URI")
getSimklCodeUrl := "https://simkl.com/oauth/authorize?response_type=code&client_id=" + Environment.SIMKL_CLIENT_ID + "&redirect_uri=" + Environment.SIMKL_CALLBACK_URI
runtime.BrowserOpenURL(a.ctx, getSimklCodeUrl)
serverDone := &sync.WaitGroup{}
@ -127,9 +126,9 @@ func getSimklAuthorizationToken(content string) SimklJWT {
Code string `json:"code"`
}{
GrantType: "authorization_code",
ClientID: os.Getenv("SIMKL_CLIENT_ID"),
ClientSecret: os.Getenv("SIMKL_CLIENT_SECRET"),
RedirectURI: os.Getenv("SIMKL_CALLBACK_URI"),
ClientID: Environment.SIMKL_CLIENT_ID,
ClientSecret: Environment.SIMKL_CLIENT_SECRET,
RedirectURI: Environment.SIMKL_CALLBACK_URI,
Code: content,
}
jsonData, err := json.Marshal(data)
@ -171,7 +170,7 @@ func (a *App) GetSimklLoggedInUser() SimklUser {
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
req.Header.Add("simkl-api-key", os.Getenv("SIMKL_CLIENT_ID"))
req.Header.Add("simkl-api-key", Environment.SIMKL_CLIENT_ID)
response, err := client.Do(req)
@ -203,6 +202,7 @@ func (a *App) LogoutSimkl() string {
if err != nil {
fmt.Println("Simkl Logout Failed", err)
}
simklJwt = SimklJWT{}
}
return "Simkl Logged Out Successfully"