Skip to content

Add ability to initialise API object using OAUTH details #61

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
further-reading opened this issue Aug 6, 2018 · 3 comments · Fixed by #125
Closed

Add ability to initialise API object using OAUTH details #61

further-reading opened this issue Aug 6, 2018 · 3 comments · Fixed by #125
Assignees

Comments

@further-reading
Copy link

further-reading commented Aug 6, 2018

The access_token.get method allows you to convert an OAUTH token into an access token for making API commands on a user's behalf for WebexTeams Integrations. However, currently the ciscospark package won't let you call this method unless you have already an API object, which is a problem since you need a token to make an API object even though you don't need a token to make this call!

Luckily, the constructor doesn't actually check if the token you give it is valid on creation. As a workaround, I currently initialise an API object with a fake token, use it to convert the OAUTH code into the new token and then use that new token to create another API object I'll use elsewhere. To demonstrate:

def makeAPI(client_id, client_secret, OAuthcode, redirect_uri):
    fakeAPI = CiscoSparkAPI(access_token='blahblahblah')
    tokenObject = fakeAPI.access_tokens.get(client_id, client_secret, OAuthcode, redirect_uri)
    realAPI = CiscoSparkAPI(access_token=tokenObject.access_token)
    return realAPI

Ideally, I should be able to initialise the API by calling API = CiscoSparkAPI(client_id, client_secret, OAuthcode, redirect_uri) or something like that directly.

@further-reading further-reading changed the title Add ability to initialise API object using OATH details Add ability to initialise API object using OAUTH details Aug 6, 2018
@cmlccie cmlccie self-assigned this Jan 3, 2019
@cmlccie
Copy link
Collaborator

cmlccie commented Apr 2, 2019

@sQu4rks added this functionality via #76 , which has been merged into master. I will push a release to PyPI shortly with the new functionality. We still need tests and docs for the code.

@sQu4rks
Copy link
Contributor

sQu4rks commented Apr 2, 2019

I'll be looking into the tests and docs for this as well @cmlccie

@cmlccie
Copy link
Collaborator

cmlccie commented Apr 4, 2019

Thank you @sQu4rks !

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
3 participants