File: example_test.go

package info (click to toggle)
golang-github-azuread-microsoft-authentication-extensions-for-go 0.0~git20231002.7e3b8e2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 260 kB
  • sloc: makefile: 4
file content (31 lines) | stat: -rw-r--r-- 946 bytes parent folder | download
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

package cache_test

import (
	"github.com/AzureAD/microsoft-authentication-extensions-for-go/cache"
	"github.com/AzureAD/microsoft-authentication-extensions-for-go/cache/accessor"
	"github.com/AzureAD/microsoft-authentication-library-for-go/apps/public"
)

// This example shows how to configure an MSAL public client to store data in a peristent, encrypted cache.
func Example() {
	// On Linux and macOS, "s" is an arbitrary name identifying the cache.
	// On Windows, it's the path to a file in which to store cache data.
	s := "..."
	a, err := accessor.New(s)
	if err != nil {
		// TODO: handle error
	}
	c, err := cache.New(a, s)
	if err != nil {
		// TODO: handle error
	}
	app, err := public.New("client-id", public.WithCache(c))
	if err != nil {
		// TODO: handle error
	}

	_ = app
}