EdgeGrid for Node.js
link for more details).
This version of EdgeGrid for Node.js has updated log4js version from 0.6.14 to 1.0.0 to fix issues with SemVer plugin for webpack (see thisnpm and use it as described here while the official EdgeGrid for Node.js is not updated with this change.
You can get it inThis library implements an Authentication handler for the Akamai OPEN EdgeGrid Authentication scheme in Node.js For more infomation visit the Akamai {OPEN} Developer Portal.
Installation
npm install --save edgegrid-updated-log4js
Example
Credentials
To use the Akamai OPEN APIs you must first register and authorize a set of credentials through the LUNA Control Center. More information on creating and authorizing credentials can be found at https://developer.akamai.com/introduction/Prov_Creds.html
.edgerc Authentication
The preferred method of using the library involves providing the path to an '.edgerc' file which contains the authenticaion credentials which will be used to sign your requests.
NOTE: Requests to the API are signed with a timestamp and therefore should be executed immediately.
var EdgeGrid = ; var data = 'bodyData'; // Supply the path to your .edgerc file and name// of the section with authorization to the client// you are calling (default section is 'default')var eg = path: '/path/to/.edgerc' section: 'section-name'; eg; eg;
An .edgerc
file contains sections of credentials and is usually hosted in your home directory:
[default]host = akaa-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.luna.akamaiapis.net/client_token = akab-XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXclient_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXaccess_token = akab-XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXmax-body = 131072 [section-name]host = akaa-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.luna.akamaiapis.net/client_token = akab-XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXclient_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXaccess_token = akab-XXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXmax-body = 131072
Manual Authentication
In addition supplying credentials via an .edgerc file as above, you may also authenticate manually by hard-coding your credential values and passing them to the EdgeGrid client:
var clientToken = "akab-client-token-xxx-xxxxxxxxxxxxxxxx" clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=" accessToken = "akab-access-token-xxx-xxxxxxxxxxxxxxxx" baseUri = "https://akaa-baseurl-xxxxxxxxxxx-xxxxxxxxxxxxx.luna.akamaiapis.net/"; var eg = clientToken clientSecret accessToken baseUri;
Chaining
Calls using the edgegrid client can also be chained as per the following;
...eg;
Headers
Headers for the request must be supplied in an object as name : value pairs. You do not need to supply form-data headers or content lengths - that will cause authentication headers on the API.
eg;
Body Data
The request BODY can be provided as either an object or as a POST data formed string.
// Objecteg;
Query String Pameters
Query string parameters must be supplied in an Object as name : value pairs and
passed to the auth
method under the qs
property.
eg; // Produces request url similar to:// http://hostaddress.luna.akamaiapis.net/diagnostic-tools/v1/dig?hostname=developer.akamai.com&queryType=A&location=location
Debug
Edgegrid accepts a --debug flag which, when passed, will cause the script to output additional information about the reqest that can be useful in debugging.
The debug option can be passed in as part of the Edgegrid instantiation object or as a command line argument.
// Set debug via Edgegrid propertyvar eg = path: edgercPath section: sectionName debug: true;
// Set debug via commmand line argument$ node src/diagnostic-tools.js --debug Preparedbody: {}REQUEST
Reporting a bug
To report a bug simply create a new GitHub Issue and describe your problem or suggestion.
Before reporting a bug look around to see if there are any open or closed tickets that cover your issue, and check the Akamai OPEN Developer Community to see if there are any posts that might address your concern. And remember the wisdom: pull request > bug report > tweet!
Contributors
A huge thanks to Jonatahn Bennett for creating and maintaining the original iteration of this project and to the following contributors:
NOTE: If you'd like to contribute please feel free to create a fork and submit a pull request.
License
Copyright 2016 Akamai Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.