Skip to content

Generate SAS tokens for the Azure APIM Direct Management REST API with Golang

License

Notifications You must be signed in to change notification settings

iambenzo/apimsas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go.Dev reference go report card Test

This module exposes a Provider struct which can be used to generate SAS tokens for authenticating with Azure's APIM Management API.

Setup

If you haven't already, enable APIM's Management API by navigating to your APIM resource in the Azure Portal and using the pane's navigation bar on the left to find and select "Management API". From there, toggle "Enable Management REST API" to Yes.

Microsoft's documentation for the above steps can be found here.

Once activated, on the same page, locate the "Credentials" section and take note of your Identifier and either your Primary key, or Secondary key. These will be used when instantiating the Provider struct as id and key respectively.

Usage

package main

import (
	"github.com/iambenzo/apimsas"
	"fmt"
)

func main() {

    // Instantiate token provider
	sas := apimsas.NewApimSasProvider("identifier", "primary/secondary key")

    // Generate token
	token, err := sas.GetSasToken()

	if err != nil {
		fmt.Printf("%v\n", err)
	}

    // Show off our generated token
	fmt.Printf("%s\n", token)

    // Make API requests from here...
}

Microsoft's documentation on the API Management REST API can be found here.

About

Generate SAS tokens for the Azure APIM Direct Management REST API with Golang

Topics

Resources

License

Stars

Watchers

Forks

Languages