Files
AstralCalendar/main/main.go
T
2026-08-06 14:54:20 -04:00

40 lines
957 B
Go

package main
import (
"context"
"net/http"
"astraltech.xyz/calendar/v2/auth"
"astraltech.xyz/calendar/v2/caldav"
"astraltech.xyz/calendar/v2/webserver"
)
func handleUser(w http.ResponseWriter, r *http.Request) {
// Load the stored token
token, err := auth.TestTokenStore.Load()
if err != nil {
http.Error(w, "Not authenticated", http.StatusUnauthorized)
return
}
// Create an HTTP client that attaches the access token
client := auth.OAuthConfigs[0].Client(context.Background(), token)
}
func main() {
auth.CreateTestOAuth()
read_config()
caldav.InitDavClient(serverConfig.URL)
webserver.ServeLoginPage("/login", webserver.CustomizableLoginData{
ServiceName: "Astral Calendar",
AuthRequestFunction: auth.HandleAuthRequest,
})
webserver.ServeWebpage("/callback", auth.OAuthCallback)
webserver.ServeWebpage("/user", handleUser)
webserver.EnableLogoRoute()
webserver.EnableStaticRoute()
webserver.ServeWebserver()
}