Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Introduce token exchange api #1036

Merged
merged 5 commits into from
Nov 13, 2023
Merged

Introduce token exchange api #1036

merged 5 commits into from
Nov 13, 2023

Conversation

rezaansyed
Copy link
Contributor

@rezaansyed rezaansyed commented Nov 6, 2023

WHY are these changes introduced?

Introduces token exchange API. The API to fetch access tokens is based on the Token Exchange spec:

 POST https://{shop_url}/admin/oauth/access_token

Parameters:

Parameter Description
client_id REQUIRED The api key for the app
client_secret REQUIRED The client secret for the app.
grant_type REQUIRED The value urn:ietf:params:oauth:grant-type:token-exchange indicates that a token exchange is being performed. Not required for authorization code grant flow
subject_token REQUIRED ID token that represents the identity & active browser session of a merchant using the app.
subject_token_type REQUIRED The value urn:ietf:params:oauth:token-type:id_token indicates that the subject token type is an ID token.
requested_token_type OPTIONAL urn:shopify:params:oauth:token-type:offline-access-token (Default) and urn:shopify:params:oauth:token-type:online-access-token are valid types for requesting offline & online access tokens, respectively.

WHAT is this pull request doing?

Introduces API gated behind the unstable_tokenExchange future flag.

Type of change

  • Patch: Bug (non-breaking change which fixes an issue)
  • Minor: New feature (non-breaking change which adds functionality)
  • Major: Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have used yarn changeset to create a draft changelog entry (do NOT update the CHANGELOG.md file manually)
  • I have added/updated tests for this change
  • I have documented new APIs/updated the documentation for modified APIs (for public APIs)

@rezaansyed rezaansyed self-assigned this Nov 6, 2023
@rezaansyed rezaansyed force-pushed the introduce-token-exchange-api branch 5 times, most recently from 8efb29d to 1426e37 Compare November 7, 2023 20:44
@rezaansyed rezaansyed marked this pull request as ready for review November 7, 2023 21:39
@rezaansyed rezaansyed requested a review from a team as a code owner November 7, 2023 21:39
Copy link
Contributor

@paulomarg paulomarg left a comment

Choose a reason for hiding this comment

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

Love it! I'll let the team review it as well, but I can't see anything I'd change other than the ShopifyAuth types.

packages/shopify-api/lib/auth/index.ts Outdated Show resolved Hide resolved
packages/shopify-api/lib/auth/oauth/create-session.ts Outdated Show resolved Hide resolved
strA: string | {[key: string]: string} | string[] | number[],
strB: string | {[key: string]: string} | string[] | number[],
) => boolean;

export function safeCompare(
Copy link
Contributor

Choose a reason for hiding this comment

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

Total nit, but we could export this as an arrow function so we don't have to repeat the types:

Suggested change
export function safeCompare(
export const safeCompare: SafeCompare = (strA, strB) => {

@rezaansyed rezaansyed merged commit 6c2274a into main Nov 13, 2023
10 checks passed
@rezaansyed rezaansyed deleted the introduce-token-exchange-api branch November 13, 2023 14:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants