Skip to content
Switch branches/tags
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


Akamai {OPEN} EdgeGrid Authentication for ruby (net/http)

This library implements the Akamai {OPEN} EdgeGrid Authentication scheme for the ruby net/http library.

For more information visit the Akamai {OPEN} Developer Community.


This library requires ruby v1.9 or later. To easily install we recommend using rbenv, rubygems and bundler

  • Install from rubygems
gem install akamai-edgegrid
  • Install from sources (we assume you already have rbenv going)
rbenv local 2.5.3
gem install bundler
bundle install
rake test
gem build akamai-edgegrid.gemspec
gem install akamai-edgegrid-1.0.gem


require 'akamai/edgegrid'
require 'net/http'
require 'uri'

baseuri = URI('')

http =,

    :client_token => 'ccccccccccccccc',
    :client_secret => 'sssssssssssssssssssssss',
    :access_token => 'aaaaaaaaaaaaaaaaaaaa',
    :max_body => 128 * 1024

# example of simple GET request
request = URI.join(baseuri.to_s, '/diagnostic-tools/v1/locations').to_s
response = http.request(request)
puts response.body

# exmaple of POST request with a json formatted request body

require 'json'
account_id = 'account-id-goes-here'
start_time = * 1000
end_time = start_time + 86400000

post_request =
    URI.join(baseuri.to_s, "/events/v2/#{account_id}/events").to_s,
    initheader = { 'Content-Type' => 'application/json' }

post_request.body = {
    "name" => "A test event",
    "start" => start_time,
    "end" => end_time

post_response = http.request(post_request)
puts post_response.body
  1. First initialize a new EdgegridHTTP object. This is a subclass of Net::HTTP and thus has all methods from that class avaialble for use.

  2. Next initialize the configuration of Edgegrid via the setup_edgegrid method. You must pass the :client_token, and :client_secret from the "Credentials" screen of the Manage APIs UI and the :access_token from the "Authorizations" section of the Manage APIs UI.

  3. Finally, use Net::HTTP methods as usual. EdgegridHTTP will add the property Authentication header to sign your http messages.

Alternate Method using .edgerc

If you want to use the .edgerc method of authentication, similar to the python, php and Perl examples, you can find information on how to create the file on the developer portal in the Introduction section. If you are using the .edgerc file the example code is a little different:

require 'akamai/edgegrid'
require 'net/http'
require 'uri'

http =, 443)

baseuri = URI('https://' +

http.setup_from_edgerc({:section => 'default'})

request = URI.join(baseuri.to_s, 'diagnostic-tools/v1/locations').to_s
response = http.request(request)
puts response.body

All other methods should work exactly the same.


Jonathan Landis


Copyright 2014 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

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.


This library implements the Akamai OPEN EdgeGrid Authentication scheme for the ruby net/http library.





No packages published

Contributors 4