Bynder / bynder-js-sdk

SDK in JavaScript (Node.js) for integration with Bynder
MIT License
36 stars 41 forks source link

OAuth2 permanent token not working #40

Closed emadicio closed 2 years ago

emadicio commented 4 years ago

Hey,

I was using OAuth1 and was working fine, but it seems like this library has been updated to OAuth2-only support. If I try to use my permanent OAuth2 token in the new way:

const bynder = new Bynder({
    baseURL: 'https://MY_ORGANIZATION.getbynder.com/api/',
    clientId: 'MY_CLIENT_ID',
    clientSecret: 'MY_CLIENT_SECRET',
    token: {
      access_token:
        'MY_PERMANENT_ACCESS_TOKEN',
    },
  });

i receive an error message with code 401. Could you please provide guidance on how to authenticate with my permanent access token?

Thank you.

danielsequeira commented 4 years ago

Hi @emadicio,

From the release/tag 2.0.0 forwards of the SDK OAuth 1.0a support was removed, this new release only supports OAuth 2.0.

This is due to the fact that in the long term we do want to deprecate OAuth 1.0a in Bynder and only use OAuth 2.0. At the moment we don't have an official plan or timeline for the deprecation, which might still take a while.

In the meantime to still make use of OAuth 1.0a and permanent tokens, you will need to use one of the previous releases/tags.

Regarding permanent tokens for our OAuth 2.0 service we just finished implementing it. And at the moment we are adding this functionality to all our SDKs, what should be finished some time during next week.

bitno commented 4 years ago

Hi @danielsequeira,

Any update on the permanent token authentication with OAuth 2.0? We are moving to 2.0 at the moment and have not been able to make the authentication work.

Any help would be highly appreciated.

Regards, Leo

rcuisnier commented 4 years ago

Hi @bitno , @emadicio ,

It should work using this method as indicated in readme :

Using a permanent token

const bynder = new Bynder({ baseURL: "https//portal.getbynder.com/api/", permanentToken: "", });

ricokahler commented 3 years ago

@rcuisnier I've tried using the permanent token as described by the readme here but it's not working for me for calls like getAssetUsage.

I think I found the potential bug here:

https://github.com/Bynder/bynder-js-sdk/blob/713143daf3ec98edd8643e5d1700f26991b650b1/src/bynder-js-sdk.js#L531-L538

getAssetUsage does not use this.api and instead creates a new APICall instance where the permanent token is not passed in.

elseee commented 2 years ago

Fixed in v2.3.9