1
- require " omniauth-oauth2"
1
+ require ' omniauth-oauth2'
2
2
3
3
module OmniAuth
4
4
module Strategies
5
5
class Qualtrics < OmniAuth ::Strategies ::OAuth2
6
-
7
- option :name , "qualtrics"
6
+ option :name , 'qualtrics'
8
7
9
8
option :client_options ,
10
- site : " https://co1.qualtrics.com" ,
11
- authorize_url : " /oauth2/auth" ,
12
- token_url : " /oauth2/token"
9
+ site : ' https://co1.qualtrics.com' ,
10
+ authorize_url : ' /oauth2/auth' ,
11
+ token_url : ' /oauth2/token'
13
12
14
13
# Qualtrics does use state but we want to control it rather than letting
15
14
# omniauth-oauth2 handle it.
@@ -19,26 +18,31 @@ class Qualtrics < OmniAuth::Strategies::OAuth2
19
18
20
19
info do
21
20
{
22
- " url" => access_token . client . site
21
+ ' url' => access_token . client . site
23
22
}
24
23
end
25
24
25
+ def callback_url
26
+ full_host + script_name + callback_path
27
+ end
28
+
26
29
# Override authorize_params so that we can be deliberate about the value for state
27
30
# and not use the session which is unavailable inside of an iframe for some
28
31
# browsers (ie Safari)
29
32
def authorize_params
30
33
# Only set state if it hasn't already been set
31
34
options . authorize_params [ :state ] ||= SecureRandom . hex ( 24 )
32
- params = options . authorize_params . merge ( options_for ( "authorize" ) )
35
+ options . authorize_params [ :scope ] = 'manage:all'
36
+ params = options . authorize_params . merge ( options_for ( 'authorize' ) )
33
37
if OmniAuth . config . test_mode
34
38
@env ||= { }
35
- @env [ " rack.session" ] ||= { }
39
+ @env [ ' rack.session' ] ||= { }
36
40
end
37
41
params
38
42
end
39
-
40
43
end
41
44
end
42
45
end
43
46
44
- OmniAuth . config . add_camelization "qualtrics" , "Qualtrics"
47
+ OmniAuth . config . add_camelization 'qualtrics' , 'Qualtrics'
48
+
0 commit comments