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

athentication-refresh token access with SDK #31

Closed
tedatkc opened this issue Dec 2, 2022 · 3 comments
Closed

athentication-refresh token access with SDK #31

tedatkc opened this issue Dec 2, 2022 · 3 comments

Comments

@tedatkc
Copy link

tedatkc commented Dec 2, 2022

Trying to access our Bynder instance with the python SDK. I've tried the "getting started" and running into problems.

I've submitted a ticket 160448 and they redirected me here.

from bynder_sdk import BynderClient

bynder_client = BynderClient(
    domain=DOMAIN,
    redirect_uri='https://localhost/callback',
    client_id=CLIENTID,
    client_secret=CLIENTSECRET
)

print(bynder_client.get_authorization_url())
code = input('Code: ')
bynder_client.fetch_token(code)

asset_bank_client = bynder_client.asset_bank_client
media_list = asset_bank_client.media_list({
    'limit': 2,
    'type': 'image'
})


# ERROR
# TypeError: Missing required arguments: ['scopes']
# 
# %%
bynder_client = BynderClient(
    domain=DOMAIN,
    redirect_uri='https://localhost/callback',
    client_id=CLIENTID,
    client_secret=CLIENTSECRET,
    scopes=['offline',
            'asset:read',
            'meta.assetbank:read'],
)

print(bynder_client.get_authorization_url())
code = input('Code: ')
bynder_client.fetch_token(code)

asset_bank_client = bynder_client.asset_bank_client
media_list = asset_bank_client.media_list({
    'limit': 2,
    'type': 'image'
})

# RESPONSE:
#    ('https://https://[MYDOMAIN]/v6/authentication/
#      oauth2/auth?response_type=code&client_id=[MYCLIENTID]&
#      redirect_uri=https%3A%2F%2Flocalhost%2Fcallback.&scope=offline+asset%3Aread+
#      meta.assetbank%3Aread&state=ElNUPvMv', 'ElNUPvMv')
#
# ENTERED CODE from state above...
#    Code: ElNUPvMv
#
# ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries 
# exceeded with url: //[MYDOMAIN]/v6/authentication/oauth2/token 
# (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] 
# getaddrinfo failed'))
@TimBloembergen
Copy link

Hi @tedatkc ,

In your bynder_client you are not passing the scopes parameter, which is why you get the error "Missing required arguments: ['scopes'] error.

Please have a look at our example app,

bynder_client = BynderClient(
domain='portal.getbynder.com',
redirect_uri='',
client_id='',
client_secret='',
scopes=['offline', 'asset:read', 'meta.assetbank:read'],
token=token, # optional, if we already have one
token_saver=token_saver, # optional, defaults to empty lambda

https://github.com/Bynder/bynder-python-sdk/tree/master/example

@tedatkc
Copy link
Author

tedatkc commented Dec 5, 2022

Sorry. I wasn't very clear. The first example from the "getting started" didn't work -- I think that warrants changes the documentation under "getting started".

A little farther down, I use the scopes argument and it still doesn't work.

# %%
bynder_client = BynderClient(
    domain=DOMAIN,
    redirect_uri='https://localhost/callback',
    client_id=CLIENTID,
    client_secret=CLIENTSECRET,
    scopes=['offline',
            'asset:read',
            'meta.assetbank:read'],
)

print(bynder_client.get_authorization_url())
code = input('Code: ')
bynder_client.fetch_token(code)

asset_bank_client = bynder_client.asset_bank_client
media_list = asset_bank_client.media_list({
    'limit': 2,
    'type': 'image'
})

# RESPONSE:
#    ('https://https://[MYDOMAIN]/v6/authentication/
#      oauth2/auth?response_type=code&client_id=[MYCLIENTID]&
#      redirect_uri=https%3A%2F%2Flocalhost%2Fcallback.&scope=offline+asset%3Aread+
#      meta.assetbank%3Aread&state=ElNUPvMv', 'ElNUPvMv')
#
# ENTERED CODE from state above...
#    Code: ElNUPvMv
#
# ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries 
# exceeded with url: //[MYDOMAIN]/v6/authentication/oauth2/token 
# (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 11001] 
# getaddrinfo failed'))

@tedatkc
Copy link
Author

tedatkc commented Dec 5, 2022 via email

@tedatkc tedatkc mentioned this issue Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants