summaryrefslogtreecommitdiff
path: root/internal/platforms/linkedin/oauth2
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-11-08 23:04:51 +0200
committerPaul Buetow <paul@buetow.org>2024-11-08 23:04:51 +0200
commit5ee4d7a6020e32159e735ff9e5b38be5da6bfe9c (patch)
treecabe16c43c3ffa4a6f55c2c3095b30bfc809aa9f /internal/platforms/linkedin/oauth2
parent9b14c12e0ccd5c96dd9f17d1b20fe134308d2184 (diff)
dont use logger but color outputter
Diffstat (limited to 'internal/platforms/linkedin/oauth2')
-rw-r--r--internal/platforms/linkedin/oauth2/oauth2.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/internal/platforms/linkedin/oauth2/oauth2.go b/internal/platforms/linkedin/oauth2/oauth2.go
index 9a6c84d..51beec9 100644
--- a/internal/platforms/linkedin/oauth2/oauth2.go
+++ b/internal/platforms/linkedin/oauth2/oauth2.go
@@ -6,12 +6,12 @@ import (
"errors"
"fmt"
"io"
- "log"
"net/http"
"os/exec"
"runtime"
"time"
+ "codeberg.org/snonux/gos/internal/colour"
"codeberg.org/snonux/gos/internal/config"
"golang.org/x/oauth2"
"golang.org/x/oauth2/linkedin"
@@ -72,7 +72,7 @@ func oauthCallbackHandler(w http.ResponseWriter, r *http.Request) {
defer close(errCh)
code := r.URL.Query().Get("code")
- log.Println("Exchanging OAuth2 token")
+ colour.Infoln("Exchanging OAuth2 token")
token, err := oauthConfig.Exchange(globalCtx, code)
if err != nil {
_, _ = w.Write([]byte(err.Error()))
@@ -110,7 +110,7 @@ func LinkedInCreds(ctx context.Context, args config.Args) (string, string, error
http.HandleFunc("/callback", oauthCallbackHandler)
http.HandleFunc("/up", upHandler)
- log.Println("Listening on http://localhost:8080 for LinkedIn OAuth2")
+ colour.Infoln("Listening on http://localhost:8080 for LinkedIn OAuth2")
go func() {
if err := http.ListenAndServe(":8080", nil); err != nil {
errCh <- err
@@ -139,7 +139,7 @@ func LinkedInCreds(ctx context.Context, args config.Args) (string, string, error
}
func openURLInFirefox(browser, url string) error {
- log.Println("Opening", url, "in", browser)
+ colour.Infoln("Opening", url, "in", browser)
switch runtime.GOOS {
case "windows":
cmd := exec.Command("cmd", "/C", "start", browser, url)
@@ -162,9 +162,11 @@ func WaitUntilURLIsReachable(url string) error {
resp, err := http.Get(url)
if err != nil {
- log.Printf("URL is not reachable: %v\n", err)
+ colour.Infof("URL is not reachable: %v", err)
+ fmt.Print("\n")
} else {
- log.Printf("URL is reachable: %s - Status Code: %d\n", url, resp.StatusCode)
+ colour.Infof("URL is reachable: %s - Status Code: %d", url, resp.StatusCode)
+ fmt.Print("\n")
resp.Body.Close()
return nil
}