msotoken

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 6 Imported by: 0

README

mso-token

Fetch microsoft online access token by using microsoft-authentication-library-for-go

Installation

Setting Up Go

To install Go, visit this link.

Installing Module

go get -u github.com/kangchengkun/mso-token

Usage

Before using this Go module, you will need to register your application with the Microsoft identity platform.

Get the AAD tenant and application information from your microsoft online Administrator

import github.com/kangchengkun/mso-token

msotoken.TenantID = "your-tenant-id"
msotoken.ClientID = "your-client-id"
msotoken.ClientSecret = "your-client-secret"

// Change the default cache time
msotoken.DefaultCacheTime = 10 * time.Minute

// Change the default permission scopes
msotoken.PermissionScopes = []string{"https://outlook.office365.com/.default"}


// Fetch token
accessToken, err := msotoken.GetToken()
if err != nil {
    fmt.Println("Fetch access token failed")
}

Contribution

Follow the Guide to publish new versions

...
git add .
git commit -m "new updates"

$ git tag vx.x.x
$ git push origin vx.x.x

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// the tenant id from microsoft Azure Active Directory, ask from administrators
	TenantID string
	// the application client id to fetch token from microsoft online, ask from administrators
	ClientID string
	// the application client secret to fetch token from microsoft online, ask from administrators
	ClientSecret string
	// the permission scope required for microsoft EWS online
	PermissionScopes []string = []string{"https://outlook.office365.com/.default"}
	// the authority base url for microsoft EWS online
	AuthorityBaseUrl string = "https://login.microsoftonline.com/"
	// cache instance with a default expiration time of 5 minutes, and which purges expired items every 10 minutes
	CacheIns *cache.Cache = cache.New(5*time.Minute, 10*time.Minute)
	// the default cache time
	DefaultCacheTime time.Duration = cache.DefaultExpiration
)

Functions

func GetToken

func GetToken() (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL