The main goal of this package is to hold any logic related to the aquisition/refreshing/invalidation generated by Edgio REST API client.
token.GetAccessToken(credentials common.Creds) (string, error)
This func outsources the process of getting an auth token from Edgio’s Auth service. It assumes Edgio’s standard auth endpoint as a default URL, but that can be overwritten by your own, in the event of an enterprise/self-hosted app.
It will double check of the credentials are present, and return an error if they are not, and then perform the HTTP request needed to get an access token to be used on the other edgio endpoints.
credentials = common.Creds{
Key: "some-clinet-key",
Secret: "some-clinet-secret",
Scopes: "some-scopes",
AuthURL: "optional-auth-url",
}
token.GetAccessToken(credentials) // returns the access token in plain text
token.GetAccessToken
Mandatory Paramscredentials common.Creds
common.Creds.Key
: Edgio REST API Client Key. This is the API Client’s identifier on Edgio. You can generate your api client accessing https://edgio.app/<your-org-name>/clients
.common.Creds.Secret
: Edgio REST API Client Secret. This is the API Client’ secret, unique for each API Client. You can generate your api client accessing https://edgio.app/<your-org-name>/clients
.token.GetAccessToken
Optional Params & Default Valuescredentials common.Creds
common.Creds.Scopes
: Edgio REST API Client scopes requested by the client. Different APIs needs different scopes. Refer to the REST API docs to figure which ones you need.
app.cache+app.cache.purge+app.waf+app.waf:edit+app.waf:read+app.accounts+app.config
(all scopes).common.Creds.AuthURL
: Edgio REST API auth url. You will probably never need to change this, but we included the option just in case (e. g.: future enterprise self-hosted option).
https://id.edgio.app/connect/token
(Edgio’s default auth API url).