47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package config
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
type OAuthProviderConfig struct {
|
|
ClientID string
|
|
ClientSecret string
|
|
RedirectURI string
|
|
AuthURL string
|
|
TokenURL string
|
|
}
|
|
|
|
type OAuthConfig struct {
|
|
EncryptionKey string
|
|
AppURL string
|
|
Garmin OAuthProviderConfig
|
|
Wahoo OAuthProviderConfig
|
|
}
|
|
|
|
var OAuth *OAuthConfig
|
|
|
|
func InitOAuth() {
|
|
OAuth = &OAuthConfig{
|
|
EncryptionKey: os.Getenv("OAUTH_ENCRYPTION_KEY"),
|
|
AppURL: os.Getenv("APP_URL"),
|
|
Garmin: OAuthProviderConfig{
|
|
ClientID: os.Getenv("GARMIN_CLIENT_ID"),
|
|
ClientSecret: os.Getenv("GARMIN_CLIENT_SECRET"),
|
|
RedirectURI: os.Getenv("GARMIN_REDIRECT_URI"),
|
|
AuthURL: "https://apis.garmin.com/tools/oauth2/authorizeUser",
|
|
TokenURL: "https://diauth.garmin.com/di-oauth2-service/oauth/token",
|
|
},
|
|
Wahoo: OAuthProviderConfig{
|
|
ClientID: os.Getenv("WAHOO_CLIENT_ID"),
|
|
ClientSecret: os.Getenv("WAHOO_CLIENT_SECRET"),
|
|
RedirectURI: os.Getenv("WAHOO_REDIRECT_URI"),
|
|
AuthURL: "https://api.wahooligan.com/oauth/authorize",
|
|
TokenURL: "https://api.wahooligan.com/oauth/token",
|
|
},
|
|
}
|
|
|
|
log.Println("OAuth config initialized")
|
|
}
|