Skip to content
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

Add a state param to create_permission_url #467

Closed
wants to merge 1 commit into from

Conversation

drewish
Copy link

@drewish drewish commented Sep 19, 2018

Fixes #466

@@ -73,9 +73,10 @@ def initialize(url, token = nil, extra = {})
self.extra = extra
end

def create_permission_url(scope, redirect_uri = nil)
params = {:client_id => api_key, :scope => scope.join(',')}
def create_permission_url(scope, redirect_uri = nil, state: nil)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to named parameters seemed better long term but makes for sort of a wonky interface right now.

Copy link

@richter-alex richter-alex Oct 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would we think about instead consolidating into an options hash? CC @jamiemtdwyer

def create_permission_url(scope, options = {})
      params = {:client_id => api_key, :scope => scope.join(',')}
      params[:redirect_uri] = options[:redirect_uri] if options[:redirect_uri]
      params[:state] = options[:state] if options[:state]
      "#{site}/oauth/authorize?#{parameterize(params)}"
end

create_permission_url(["read_orders"], { redirect_uri: "baz.myshopify.com", state: "foobar" })

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidating into an options hash isn't a bad idea. I like it because it's future proof, it allows extending this in the future to support generating online access tokens without changing the public API again. That being said, I think I would keep redirect_uri and actually remove the defaulting to nil, since redirect_uri is required now.

I don't much like the idea of mixing keyword and positional arguments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamiemtdwyer Just so I'm clear before I try to go get all those tests changed around: You're okay with a breaking to the interface that makes the redirect_uri a required parameter? So we'll have a method like:

    def create_permission_url(scope, redirect_uri, state: nil)
      params = { client_id: api_key, scope: scope.join(','), redirect_uri: redirect_uri }
      params[:state] = state if state
      "#{site}/oauth/authorize?#{parameterize(params)}"
    end

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do I need to make changes to the readme or were you planning on handling that?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the README where necessary would be super appreciated as part of this PR

def create_permission_url(scope, redirect_uri = nil)
params = {:client_id => api_key, :scope => scope.join(',')}
def create_permission_url(scope, redirect_uri = nil, state: nil)
params = {client_id: api_key, scope: scope.join(',')}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we're only using ruby 2+ now so we can switch off the old style hashes right?

@jdjkelly
Copy link
Contributor

@drewish just ran into the lack of this feature - and not using omniauth in my codebase if I don't need to

looks like you need to sign the CLA? since this is so old, I'm happy to open a new pull request inspired by it if you've moved on - lmk

@drewish
Copy link
Author

drewish commented Jan 11, 2020

Yeah not using this gem any more so I’ll close it and let someone else give it a clean shot.

@drewish drewish closed this Jan 11, 2020
@jdjkelly
Copy link
Contributor

@drewish awesome thanks! I'll pick the idea up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create_permission_url does not accept state parameter
5 participants