-
Notifications
You must be signed in to change notification settings - Fork 474
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
Allow custom scopes during the auth process #1023
Conversation
9640704
to
511daf9
Compare
begin_auth
scopes overridebdf9b6c
to
45c378b
Compare
lib/shopify_api/auth/oauth.rb
Outdated
@@ -16,9 +16,10 @@ class << self | |||
shop: String, | |||
redirect_path: String, | |||
is_online: T.nilable(T::Boolean), | |||
scope: ShopifyAPI::Auth::AuthScopes, |
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.
This should really be called scopes but we're already using scope to refer to the collection in multiple places, so I've followed that pattern.
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.
Yeah, that's true - I think this is a consequence of the authorize request and token response actually using scope
: https://shopify.dev/apps/auth/oauth/getting-started#online-access-mode
Should we call this scope_override
so that it's more obvious that this is not a required argument?
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.
👍 updated
45c378b
to
c51c59d
Compare
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.
LGTM, only non-blocking comments.
lib/shopify_api/auth/oauth.rb
Outdated
@@ -16,9 +16,10 @@ class << self | |||
shop: String, | |||
redirect_path: String, | |||
is_online: T.nilable(T::Boolean), | |||
scope: ShopifyAPI::Auth::AuthScopes, |
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.
Yeah, that's true - I think this is a consequence of the authorize request and token response actually using scope
: https://shopify.dev/apps/auth/oauth/getting-started#online-access-mode
Should we call this scope_override
so that it's more obvious that this is not a required argument?
test/auth/oauth_test.rb
Outdated
@@ -85,6 +85,13 @@ def test_begin_auth_online | |||
verify_oauth_begin(auth_route: result[:auth_route], cookie: result[:cookie], is_online: true) | |||
end | |||
|
|||
def test_custom_scope | |||
result = ShopifyAPI::Auth::Oauth.begin_auth(shop: @shop, redirect_path: "/redirect", | |||
scope: ShopifyAPI::Auth::AuthScopes.new("read_orders,write_products")) |
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.
The AuthScopes
object is capable of taking in a string / string[] and converting it, we could consider allowing any of the 3 types as the argument to make it easier on callers.
77f6808
to
475f63d
Compare
475f63d
to
a631944
Compare
Description
First party apps such as https://shopify-graphiql-app.shopifycloud.com have scopes which are set during installation, rather than being preconfigured.
There is a corresponding update to
shopify_app
: Shopify/shopify_app#1540How has this been tested?
Tested as part of the upgrade of https://shopify-graphiql-app.shopifycloud.com
Checklist:
I have updated the project documentationN/A