我正在努力将 UserVoice Single Single On 与我的 rails 应用程序集成。他们为 ruby 提供了以下类:
require 'rubygems'
require 'ezcrypto'
require 'json'
require 'cgi'
require 'base64'
module Uservoice
class Token
attr_accessor :data
USERVOICE_SUBDOMAIN = "FILL IN"
USERVOICE_SSO_KEY = "FILL IN"
def initialize(options = {})
options.merge!({:expires => (Time.zone.now.utc + 5 * 60).to_s})
key = EzCrypto::Key.with_password USERVOICE_SUBDOMAIN, USERVOICE_SSO_KEY
encrypted = key.encrypt(options.to_json)
@data = Base64.encode64(encrypted).gsub(/\n/,'') # Remove line returns where are annoyingly placed every 60 characters
end
def to_s
@data
end
end
end
我不知道如何使用它。我将此文件添加到我的 lib 目录并使用 Rails 控制台运行。我试过了:
1.9.3-p125 :013 > Uservoice::Token
=> Uservoice::Token
但不能让它真正返回选项:
Uservoice::Token.new(:guid => 1, :display_name => "jeff goldmen", :email => "jeff@google.com")
任何想法如何实际使用它?谢谢