Bynder / bynder-python-sdk

SDK in Python for integration with Bynder
MIT License
8 stars 12 forks source link

Unable to authenticate using Client Credentials #41

Open kristianandersendk opened 9 months ago

kristianandersendk commented 9 months ago

I have setup my oauth2 application in Bynder to authenticate using Client Credentials. I can authenticate using postman by calling the /token endpoint.

When connecting using the python sdk, it looks like the client credential flow is not implemented correctly. The OAuth2Session will default to a WebApplicationClient where a BackendApplicationClient would be needed for client credential authentication.

In my current workaround im fetching the token up front, but it would be nice if the sdk could handle oauth2 authentication using client credentials

client = BackendApplicationClient(client_id='<clientId>')
oauth = OAuth2Session(client=client)
token = oauth.fetch_token(token_url='<tokenurl>', client_id='<clientId>',client_secret='<clientSecret>')

bynder_client = BynderClient(
    domain='<bynderDomain>',
    redirect_uri='', #required but should not be used
    token = token, #input the token to avoid the bynder client trying to fetch
    client_id='<clientId>', #Not used since the token is supplied
    client_secret='<clientSecret>',#Not used since the token is supplied
    scopes=['<scope>','<scope>']
)
dylanmartins commented 8 months ago

Hey @kristianandersendk sorry for the late response and thanks for the message!

We will create a ticket and look into it in the future, in the meanwhile, if you want you can also create a PR with the changes and submit it, we can code review and merge it :)