Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Add support for obtaining sync tokens #43

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

jloveridge
Copy link

Adds OAuth class and me method to the exports. The intent is to allow someone to implement their Instant Login and Secure Sync with the same library.

Also adds support for API usage via promises.

# use a promise to obtain Secure Sync tokens
Clever.OAuth.tokens(CLIENT_KEY, CLIENT_SECRET).then((tokens) =>
  # lookup the details of the token
  _.map(tokens, (token) ->
    Clever.me(token).then((details) ->
      details.token = token.access_token
      details
  )
, (err) =>
  # handle failure to obtain tokens
  console.error err, err.stack
)

# Use a promise when looking up a school
clever.School.findOne({}).exec().then((school) =>
  # do something with the school
, (err) =>
  # handle the error
  console.error err, err.stack
)

Support for bring your own promise (BYOP) is also implemented. By default the promises used will be Q promises but can be easily changed to bluebird, or any other compliant library, if you so choose.

Clever = require 'clever'
bluebird = require 'bluebird'

# set the promise provider for the Clever module
Clever.setPromiseProvider bluebird.Promise

# Use the API

@jloveridge
Copy link
Author

I sure would like to hear something regarding this pull request. Does it encompass too much? Do you want/need me to split it up into separate pull requests? Are there other issues you see with regard to the functionality provided? Ignoring pull requests for nearly a week does not encourage people to contribute to your project.

@jonahkagan
Copy link
Contributor

Hi @jloveridge - my name's Jonah, I'm the engineering manager for our Apps team. I'm really sorry for the delay. We really appreciate the contribution.

Back to school is a busy time for us (as I'm sure it is for you), so we're not currently prioritizing improvements to our client libraries. That being said, the change you've proposed here is definitely on our roadmap. I'd encourage you to keep using your fork for now, and we'll circle back with you once we're ready to make this change!

@jloveridge
Copy link
Author

@jonahkagan thanks for the update. I will definitely continue to use my fork. I also wanted to let you know the token info endpoint doesn't appear to work. I always get back a 401 error when I make a request to that service.

@jonahkagan
Copy link
Contributor

@jloveridge thanks for raising the 401 error issue. Can you email a report of the issue to [email protected] to get help troubleshooting?

@jloveridge
Copy link
Author

I will submit an issue to tech-support. However, I don't need help troubleshooting the problem as the issue is outside of my control.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants