This module exposes a Provider struct which can be used to generate SAS tokens for authenticating with Azure's APIM Management API.
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.
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.