Skip to content

Instantly share code, notes, and snippets.

@herestomwiththeweather
Created May 21, 2011 00:42
Show Gist options
  • Save herestomwiththeweather/984080 to your computer and use it in GitHub Desktop.
Save herestomwiththeweather/984080 to your computer and use it in GitHub Desktop.
create_request_token
def create_request_token(params={})
if params[:scope]
scope_uri = URI.parse(params[:scope])
# XXX ignoring host:port and assuming it's our host:port
filepath = RAILS_ROOT + '/public' + scope_uri.path
if File.exist?(filepath)
# valid asset is required
asset = CGI::parse(scope_uri.query)['asset'][0]
unless asset.blank?
group = Group.find_by_asset(asset)
RequestToken.create(:client_application => self,
:scope => params[:scope],
:group_id => group.id,
:callback_url=>self.token_callback_url) unless group.nil?
end
else
logger.info "XXX create_request_token - file not found: #{scope_uri.path}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment