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

New auth endpoint #68

Merged
merged 9 commits into from
Mar 21, 2024
Merged

New auth endpoint #68

merged 9 commits into from
Mar 21, 2024

Conversation

marcomontalbano
Copy link
Member

@marcomontalbano marcomontalbano commented Mar 19, 2024

What I did

This library now uses the new https://auth.commercelayer.io/oauth/token endpoint. I unified core and provisioning into a single authenticate method.

This is a breaking change.

Breaking changes

# no more valid
-  import { provisioning } from '@commercelayer/js-auth'

# no more valid
-  import { core } from '@commercelayer/js-auth'

# new syntax
+ import { authenticate } from '@commercelayer/js-auth'

Examples

Core authentication

import { authenticate } from '@commercelayer/js-auth'

const auth = await authenticate('client_credentials', {
  clientId: '{{ client_id }}',
  scope: 'market:id:1234'
})

Provisioning authentication

Read more about how to get the client id and secret.

import { authenticate } from '@commercelayer/js-auth'

const auth = await authenticate('client_credentials', {
  clientId: '{{ client_id }}',
  clientSecret: '{{ client_secret }}',
})

Typescript

import { authenticate, type AuthenticateOptions } from '@commercelayer/js-auth'

const options: AuthenticateOptions<'client_credentials'> = {
  clientId: '{{ client_id }}',
  scope: 'market:id:1234'
}

const auth = await authenticate('client_credentials', options)

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests).
  • Make sure to add/update documentation regarding your changes.
  • You are NOT deprecating/removing a feature.

@marcomontalbano marcomontalbano self-assigned this Mar 20, 2024
@marcomontalbano marcomontalbano marked this pull request as ready for review March 21, 2024 07:08
@marcomontalbano marcomontalbano changed the title New auth New auth endpoint Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants