Sha256: daaa04ea734323ce4edb1a3a72ef92f43d40849bd908ed416c97aa2be8f22b42

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

#!/usr/bin/env ruby
require "openid/consumer/discovery"

$names = [[:server_url,   "Server URL  "],
          [:local_id,     "Local ID    "],
          [:canonical_id, "Canonical ID"],
         ]

def show_services(user_input, normalized, services)
  puts " Claimed identifier: #{normalized}"
  if services.empty?
    puts " No OpenID services found"
    puts
  else
    puts " Discovered services:"
    n = 0
    services.each do |service|
      n += 1
      puts "  #{n}."
      $names.each do |meth, name|
        val = service.send(meth)
        if val
          printf("     %s: %s\n", name, val)
        end
      end
      puts "     Type URIs:"
      for type_uri in service.type_uris
        puts "       * #{type_uri}"
      end
      puts
    end
  end
end

ARGV.each do |openid_identifier|
  puts "=" * 50
  puts "Running discovery on #{openid_identifier}"
  begin
    normalized_identifier, services = OpenID.discover(openid_identifier)
  rescue OpenID::Yadis::DiscoveryFailure => why
    puts "Discovery failed: #{why.message}"
    puts
  else
    show_services(openid_identifier, normalized_identifier, services)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-openid-2.0.1 examples/discover