All Projects → akamai → AkamaiOPEN-edgegrid-ruby

akamai / AkamaiOPEN-edgegrid-ruby

Licence: Apache-2.0 license
This library implements the Akamai OPEN EdgeGrid Authentication scheme for the ruby net/http library.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to AkamaiOPEN-edgegrid-ruby

AkamaiOPEN-edgegrid-java
Java library for Akamai OPEN EdgeGrid Client Authentication
Stars: ✭ 37 (+94.74%)
Mutual labels:  open, akamai
AkamaiOPEN-edgegrid-php-client
PHP client library for Akamai {OPEN} EdgeGrid Authentication scheme (based on Guzzle)
Stars: ✭ 38 (+100%)
Mutual labels:  open, akamai
AkamaiOPEN-edgegrid-C-Sharp
No description or website provided.
Stars: ✭ 13 (-31.58%)
Mutual labels:  open, akamai
issue-states
GitHub Action that closes or reopens issues when they are moved to a project column
Stars: ✭ 64 (+236.84%)
Mutual labels:  open
vscode-open-in-default-browser
Open In Default Browser
Stars: ✭ 22 (+15.79%)
Mutual labels:  open
ap-monorepo
Monorepo containing all packages related to the ACTUS Protocol
Stars: ✭ 15 (-21.05%)
Mutual labels:  open
inplace
In-place file processing in Python
Stars: ✭ 21 (+10.53%)
Mutual labels:  open
detect-cloudflare-plus
True Sight Firefox extension.
Stars: ✭ 34 (+78.95%)
Mutual labels:  akamai
Open-Mam
Open Source Mobile Application Management (WORK IN PROGRESS)
Stars: ✭ 28 (+47.37%)
Mutual labels:  open
wp-akamai
No description or website provided.
Stars: ✭ 21 (+10.53%)
Mutual labels:  akamai
akamai-collector
Akamai sensor data collector with API and database support!
Stars: ✭ 60 (+215.79%)
Mutual labels:  akamai
TopWerewolf
狼人杀头条App安卓项目开源,贴吧社区。爬虫抓取了包括今日头条、优酷、sohu、百度等网站中包含狼人杀及相关的新闻
Stars: ✭ 30 (+57.89%)
Mutual labels:  open
open-electronics
📚 💻 Great Resources for Electronics Enthusiasts
Stars: ✭ 347 (+1726.32%)
Mutual labels:  open
open-on-android
Open anything on your android phone
Stars: ✭ 19 (+0%)
Mutual labels:  open
Zee5
Just a simple shit but no one knows
Stars: ✭ 29 (+52.63%)
Mutual labels:  akamai
cli-eaa
CLI for Enterprise Application Access (EAA)
Stars: ✭ 19 (+0%)
Mutual labels:  akamai
fleeg-platform
Fleeg is a free and open source platform to index and search pages.
Stars: ✭ 21 (+10.53%)
Mutual labels:  open
ExplorerGenie
ExplorerGenie is an extended context menu for the Windows explorer.
Stars: ✭ 25 (+31.58%)
Mutual labels:  open
better-opn
A better open. Reuse the same tab on Chromium-based browsers on macOS.
Stars: ✭ 30 (+57.89%)
Mutual labels:  open
NetStorageKit-Golang
Netstorage API for Golang
Stars: ✭ 17 (-10.53%)
Mutual labels:  akamai

edgegrid-ruby

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.

Installation

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

Usage

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

baseuri = URI('https://akaa-xxxxxxxxx.luna.akamaiapis.net/')

http = Akamai::Edgegrid::HTTP.new(
    address=baseuri.host,
    port=baseuri.port
)

http.setup_edgegrid(
    :client_token => 'ccccccccccccccc',
    :client_secret => 'sssssssssssssssssssssss',
    :access_token => 'aaaaaaaaaaaaaaaaaaaa',
    :max_body => 128 * 1024
)

# example of simple GET request
request = Net::HTTP::Get.new 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 = Time.now.to_i * 1000
end_time = start_time + 86400000

post_request = Net::HTTP::Post.new(
    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
}.to_json

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 = Akamai::Edgegrid::HTTP.new(get_host(), 443)

baseuri = URI('https://' + http.host)

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

request = Net::HTTP::Get.new 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.

Author

Jonathan Landis [email protected]

License

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

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].