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

[TEC-3472] Add client authorization by session_id #26

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

texpert
Copy link

@texpert texpert commented Dec 24, 2020

Pass the Flow Session id in the authorization header when syncing orders to flow.io

@paololim paololim requested review from paololim and mbryzek January 19, 2021 19:40
Copy link
Contributor

@paololim paololim left a comment

Choose a reason for hiding this comment

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

Hello @texpert - Thank you for the PR! We really appreciate the input, and recognize this is a lacking feature in our Ruby SDK.

Please note that the file lib/flow_commerce/flow_api_v0_client.rb is actually an auto-generated Ruby client by apibuilder. This is a tool we use to document our REST APIs at Flow, and generate clients across multiple languages and platforms. Manually altering this file would mean possible loss of these changes when we deploy new versions of this project.

The Ruby generator currently does not support auth schemes other than basic auth. Feel free to add an issue directly to https://github.com/apicollective/apibuilder-generator

In the meantime, a possible way around this is to override/monkeypatch Io::Flow::V0::HttpClient::Request, similar to what you did, but not on the generated file itself. This will ensure a manually created session auth will be reusable even if the file is replaced with a newly generated version.

Another way around this it to manually pass Authorization in the default_headers hash, while passing in no authorization, eg:

flow_client_with_session_auth = ::Io::Flow::V0::Client.new(
    default_headers: { "Authorization": "session XXXXXXXXXXXXX", "Other-Header": "YYYYYYYYYYY" },
    authorization: nil
)

@texpert
Copy link
Author

texpert commented Jan 24, 2021

Hello, @paololim!

Thank you for review and advise!

Meanwhile, I have opened a PR to the apibuilder-generator, please, review:

apicollective/apibuilder-generator#624

If it will happen to be acceptable, then the lib/flow_commerce/flow_api_v0_client.rb changes could be removed from the current PR, leaving only the changes to lib/flow_commerce/client.rb

texpert added a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 5, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
sebastiandl pushed a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 8, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
sebastiandl pushed a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 8, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
sebastiandl pushed a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 8, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
texpert added a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 12, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
texpert added a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 16, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
Base automatically changed from master to main March 23, 2021 20:18
texpert added a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 24, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
sebastiandl pushed a commit to mejuri-inc/flowcommerce_spree that referenced this pull request Mar 31, 2021
…ion_id specified in default headers

This is a workaround for Missing Session AuthScema proposed by the flow.io dev - flowcommerce/ruby-sdk#26 (review)

Allows to update flowcommerce gem, not depending on a fork.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants