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
|
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package main
import (
"context"
"log"
"os"
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/cache"
)
type TokenCache struct {
file string
}
func (t *TokenCache) Replace(ctx context.Context, cache cache.Unmarshaler, hints cache.ReplaceHints) error {
data, err := os.ReadFile(t.file)
if err != nil {
log.Println(err)
}
return cache.Unmarshal(data)
}
func (t *TokenCache) Export(ctx context.Context, cache cache.Marshaler, hints cache.ExportHints) error {
data, err := cache.Marshal()
if err != nil {
log.Println(err)
}
return os.WriteFile(t.file, data, 0600)
}
|