feat: generic oauth

This commit is contained in:
Stavros
2025-01-24 17:13:51 +02:00
parent f487e25ac5
commit 90f4c3c980
8 changed files with 165 additions and 33 deletions

View File

@@ -0,0 +1,35 @@
package providers
import (
"encoding/json"
"io"
"net/http"
)
type GenericUserInfoResponse struct {
Email string `json:"email"`
}
func GetGenericEmail(client *http.Client, url string) (string, error) {
res, resErr := client.Get(url)
if resErr != nil {
return "", resErr
}
body, bodyErr := io.ReadAll(res.Body)
if bodyErr != nil {
return "", bodyErr
}
var user GenericUserInfoResponse
jsonErr := json.Unmarshal(body, &user)
if jsonErr != nil {
return "", jsonErr
}
return user.Email, nil
}