Remove extra token exchange for B2B #2736
Merged
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.
Upgrade instructions
B2B methods and props are now stable. Warnings are in place for unstable usages and will be removed completely in the next major version.
Search for anywhere using
UNSTABLE_getBuyer
andUNSTABLE_setBuyer
is update accordingly.Update
createHydrogenContext
to remove theunstableB2b
optionWHY are these changes introduced?
Fixes https://github.com/Shopify/core-issues/issues/73720
With the initial support of B2B for headless we had to use a non ideal API which included an extra token exchange. Now that buyer auth as moved to core and the GraphQl API supports it, we can remove this extra token exchange and use the customer access token.
WHAT is this pull request doing?
unstableB2b
prop from the customer account client since we no longer need to do the token exchange.UNSTABLE_getBuyer
->getBuyer
andUNSTABLE_setBuyer
->setBuyer
. The logic ingetBuyer
has changed since it will now grab the customerAccountAccess token that is stored in state. From a usage perspective these functions should behave the same as before. I did this so merchants shouldn't need to change any logic other than switching the function name.HOW to test your changes?
I ran this locally for testing.
npm run dev
in the hydrogen reponpm run dev
in the B2B exampleDM me if you want to test on my store and I can add you as a B2B buyer.
Post-merge steps
Checklist