This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth' | |
consumer = { | |
key: YOUR_CONSUMER_KEY, | |
secret: YOUR_CONSUMER_SECRET | |
} | |
consumer = OAuth::Consumer.new( | |
consumer[:key], | |
consumer[:secret], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Identity::Google | |
def config | |
@config ||= OpenIDConnect::Discovery::Provider::Config.discover! Rails.application.secrets.google[:issuer] | |
end | |
def jwks | |
@jwks ||= config.jwks | |
end | |
def public_keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth' | |
callback_url = 'http://example.com/callback?foo=bar®_code=123©_code=456' | |
request_token = OAuth::Consumer.new( | |
'<CONSUMER-KEY>', | |
'<CONSUMER-SECRET>', | |
site: 'https://api.twitter.com' | |
).get_request_token( | |
oauth_callback: callback_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = ["str"] | |
str = "str" | |
puts arr[0] # => "str" | |
puts str[0] # => "s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json/jwt' | |
k = OpenSSL::PKey::EC.new('prime256v1').generate_key | |
k.to_jwk | |
# => JSON::JWK | |
jwk = JSON::JWK.new( | |
kty: "EC", | |
crv: "P-256", | |
x: "D4L5V9QocZvfuEEGfGD5YCEbIcXR-KfF7RqqZUaovJ8", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# NOTICE: | |
# JsonMarkup returns Hash, not Json text. | |
# You need to call to_json for returned target. | |
# USAGE | |
# def to_markup(markup, options = {}) | |
# markup = case format | |
# when :xml | |
# Builder::XmlMarkup.new | |
# when :json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# environment.rb | |
VERSION_DEFAULT = Version1 | |
# user.rb | |
class User | |
include Builder::UserMarkup | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'rubygems' | |
require 'json' | |
params = { | |
:context => { | |
:country => 'ALL', | |
:language => 'ja' | |
}, | |
:gadgets => [{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RequestToken < OauthToken | |
attr_accessor :provided_oauth_verifier | |
def authorize!(user) | |
return false if authorized? | |
self.user = user | |
self.authorized_at = Time.now | |
# self.verifier=OAuth::Helper.generate_key(16) | |
self.verifier=OAuth::Helper.generate_key[0,20] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'oauth' | |
htt_method = :get | |
endpoint = 'http://oauth.service-provider.com/oauth/request_token' | |
consumer_secret = 'CONSUMER_SECRET' | |
token_secret = 'ACCESS_TOKEN_SECRET' | |
request_params = { | |
# ADD ALL PARAMETERS HERE |