4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/flattr/oauth2.rb', line 4
def authorize_url(opts = {})
default_options = {
:client_id => client_id.strip,
:client_secret => client_secret.strip,
:response_type => "code"
}
opts = default_options.merge(opts)
if !opts[:scope].nil?
if opts[:scope].is_a?(Array)
opts[:scope] = opts[:scope].join(",")
end
end
query_string = %w(response_type client_id redirect_uri scope state).collect do |key|
"#{key.to_s}=#{opts[key.to_sym]}" if opts[key.to_sym]
end.compact.join("&")
"#{authorize_endpoint}/?#{query_string}"
end
|