this repo has no description
1package main 2 3import ( 4 "fmt" 5 "log/slog" 6 "net/http" 7 8 "github.com/labstack/echo/v4" 9 slogecho "github.com/samber/slog-echo" 10 "github.com/urfave/cli/v2" 11) 12 13func main() { 14 app := &cli.App{ 15 Name: "atproto-oauth-golang-tester", 16 Action: run, 17 } 18 19 app.RunAndExitOnError() 20} 21 22func run(cmd *cli.Context) error { 23 e := echo.New() 24 25 e.Use(slogecho.New(slog.Default())) 26 27 fmt.Println("atproto oauth golang tester server") 28 29 e.GET("/oauth/client-metadata.json", handleClientMetadata) 30 31 httpd := http.Server{ 32 Addr: ":7070", 33 Handler: e, 34 } 35 36 fmt.Println("starting http server...") 37 38 if err := httpd.ListenAndServe(); err != nil { 39 return err 40 } 41 42 return nil 43} 44 45func handleClientMetadata(e echo.Context) error { 46 e.Response().Header().Add("Content-Type", "application/json") 47 48 metadata := map[string]any{ 49 "client_id": "http://localhost:7070/oauth/oauth-metadata.json", 50 "client_name": "Atproto Oauth Golang Tester", 51 "client_uri": "http://localhost:7070", 52 "logo_uri": "http://localhost:7070/logo.png", 53 "tos_uri": "http://localhost:7070/tos", 54 "policy_url": "http://localhost:7070/policy", 55 "redirect_uris": []string{"http://localhost:7070/callback"}, 56 "grant_types": []string{"authorization_code", "refresh_token"}, 57 "response_types": []string{"code"}, 58 "application_type": "web", 59 "token_endpoint_auth_method": "private_key_jwt", 60 "dpop_bound_accesss_tokens": true, 61 "jwks_uri": "http://localhost:7070/jwks.json", 62 } 63 64 return e.JSON(200, metadata) 65}