forked from atomicjolt/omniauth-qualtrics
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix strategy configuration #1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
require "omniauth-oauth2" | ||
require 'omniauth-oauth2' | ||
|
||
module OmniAuth | ||
module Strategies | ||
class Qualtrics < OmniAuth::Strategies::OAuth2 | ||
|
||
option :name, "qualtrics" | ||
option :name, 'qualtrics' | ||
|
||
option :client_options, | ||
site: "https://co1.qualtrics.com", | ||
authorize_url: "/oauth2/auth", | ||
token_url: "/oauth2/token" | ||
site: 'https://co1.qualtrics.com', | ||
authorize_url: '/oauth2/auth', | ||
token_url: '/oauth2/token' | ||
|
||
# Qualtrics does use state but we want to control it rather than letting | ||
# omniauth-oauth2 handle it. | ||
|
@@ -19,26 +18,31 @@ class Qualtrics < OmniAuth::Strategies::OAuth2 | |
|
||
info do | ||
{ | ||
"url" => access_token.client.site | ||
'url' => access_token.client.site | ||
} | ||
end | ||
|
||
def callback_url | ||
full_host + script_name + callback_path | ||
end | ||
|
||
# Override authorize_params so that we can be deliberate about the value for state | ||
# and not use the session which is unavailable inside of an iframe for some | ||
# browsers (ie Safari) | ||
def authorize_params | ||
# Only set state if it hasn't already been set | ||
options.authorize_params[:state] ||= SecureRandom.hex(24) | ||
params = options.authorize_params.merge(options_for("authorize")) | ||
options.authorize_params[:scope] = 'manage:all' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not ideal--we'd rather it have just the scopes that we need, which you should be able to do by setting them in the omniauth config...but I tried that and it didn't work. We can try to look into a better solution in the future. |
||
params = options.authorize_params.merge(options_for('authorize')) | ||
if OmniAuth.config.test_mode | ||
@env ||= {} | ||
@env["rack.session"] ||= {} | ||
@env['rack.session'] ||= {} | ||
end | ||
params | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
OmniAuth.config.add_camelization "qualtrics", "Qualtrics" | ||
OmniAuth.config.add_camelization 'qualtrics', 'Qualtrics' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We got an error saying it was missing required parameters which is the same error we got with SurveyMonkey so we tried the same remedy and it worked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this overriding a method from super or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I can see if I can find the original explanation of it for SurveyMonkey...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the same change we made for SurveyMonkey user-interviews/omniauth-surveymonkey-oauth2#1
Based on an identical change for the twitch gem
Here's the original omniauth change that broke things for a lot of gems omniauth/omniauth-oauth2#70
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
twitch integration when