Initialize msal
[fbfp.git] / main.go
blobeaa99f31fdd3a6ead33625c3aa66379bd94da008
1 package main
3 import (
4 "bufio"
5 "fmt"
6 "os"
8 "git.sr.ht/~emersion/go-scfg"
9 "github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
12 var config_with_pointers struct {
13 Listen struct {
14 Port *int `scfg:"port"`
15 Bind *string `scfg:"bind"`
16 } `scfg:"listen"`
17 Msal struct {
18 Client *string `scfg:"client"`
19 Tenant *string `scfg:"tenant"`
20 Secret *string `scfg:"secret"`
21 Callback *string `scfg:"callback"`
22 } `scfg:"msal"`
25 var config struct {
26 Listen struct {
27 Port int
28 Bind string
30 Msal struct {
31 Client string
32 Tenant string
33 Secret string
34 Callback string
38 func main() {
39 f, err := os.Open("fbfp.scfg")
40 e(err)
42 err = scfg.NewDecoder(bufio.NewReader(f)).Decode(&config_with_pointers)
43 e(err)
45 config.Listen.Port = *(config_with_pointers.Listen.Port)
46 config.Listen.Bind = *(config_with_pointers.Listen.Bind)
47 config.Msal.Client = *(config_with_pointers.Msal.Client)
48 config.Msal.Tenant = *(config_with_pointers.Msal.Tenant)
49 config.Msal.Secret = *(config_with_pointers.Msal.Secret)
50 config.Msal.Callback = *(config_with_pointers.Msal.Callback)
52 cred, err := confidential.NewCredFromSecret(config.Msal.Secret)
54 _ = cred
56 fmt.Println(config)