-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_local.go
More file actions
42 lines (32 loc) · 948 Bytes
/
config_local.go
File metadata and controls
42 lines (32 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//go:build !lambda
package main
import (
"context"
"fmt"
"github.com/gw2auth/gw2auth.com-canary/oauth2"
"net/http"
"os"
)
type localRefreshTokenStore struct{}
func (localRefreshTokenStore) Load(ctx context.Context) (string, error) {
return os.Getenv("REFRESH_TOKEN"), nil
}
func (localRefreshTokenStore) Store(ctx context.Context, token string) error {
fmt.Printf("refresh_token: %s\n", token)
return nil
}
func oauth2Client(ctx context.Context) (*oauth2.Client, error) {
clientId := os.Getenv("CLIENT_ID")
clientSecret := os.Getenv("CLIENT_SECRET")
md, err := oauth2.LoadMetadataFromOAuthIssuer(ctx, "https://gw2auth.com")
if err != nil {
return nil, err
}
return oauth2.NewClient(clientId, clientSecret, md), nil
}
func refreshTokenStore() (RefreshTokenStore, error) {
return localRefreshTokenStore{}, nil
}
func applyMiddleware(ctx context.Context, handler http.Handler) (http.Handler, error) {
return handler, nil
}