Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Private image (Unit Access Only)

Attach a JWT to the request as the Authorization header. To encode it, each unit will share a “secret” (see ENV['YPM_SECRET'] in the code below) with ITS. A ruby example for creating JWT

Send an API key to the request as a bearer token in the Authorization header. Each unit will share an API key (see ENV['YPM_SECRET'] in the code below) with ITS.

An example in Ruby for creating the request:

Code Block
languageruby
require 'net/http'
require 'jwt'

# shared symmetric secret key to encrypt and decrypt the token
hmac_secret = ENV['YPM_SECRET']

payload = {
  unit: "YPM",
  iat: Time.now.to_i
}
token = JWT.encode payload, hmac_secret, 'HS512'http'

uri = URI("'http://localhost:8182images-dev.collections.yale.edu/iiif/2/ypm:85f1f218-30c1-48a4-8546-17d681f59c35.tif/full/20,/0/default.jpg")')
api_key = ENV['YPM_SECRET']

req = Net::HTTP::Get.new(uri)
req['Authorization'] = "Bearer #{tokenapi_key}"

res = Net::HTTP.start(uri.hostname, uri.port,
                      use_ssl: uri.scheme == 'https') do |http|
  http.request(req)
end

open('out.jpg', 'w') do |f|
  f.write(res.read_body)
end



Getting Stock TIFF Images

Code Block
https://media.collections.yale.edu/tiff/{unit}/{uuid}.tif

...