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

Add methods to extract and recreate access tokens #29

Merged
merged 3 commits into from Mar 6, 2017

Conversation

Projects
None yet
2 participants
@snsavage
Copy link
Contributor

commented Dec 5, 2016

Currently the unsplash_rb gem doesn't provide public methods to extract
access tokens and recreate those tokens at a later time. This makes
persisting the bearer token difficult.

This commit adds two methods to the connection class. #extract_token
uses the OAuth2 gem's OAuth2::AccessToken#to_hash method to extract a
hash that can then be persisted for later use. #create_and_assign_token
takes as a param the extract hash token, creates a new
OAuth::AccessToken object, and then assigns the new object to
@oauth_token.

Add methods to extract and recreate access tokens
Currently the unsplash_rb gem doesn't provide public methods to extract
access tokens and recreate those tokens at a later time.  This makes
persisting the bearer token difficult.

This commit adds two methods to the connection class.  #extract_token
uses the OAuth2 gem's OAuth2::AccessToken#to_hash method to extract a
hash that can then be persisted for later use.  #create_and_assign_token
takes as a param the extract hash token, creates a new
OAuth::AccessToken object, and then assigns the new object to
@oauth_token.
@aaronklaassen

This comment has been minimized.

Copy link
Member

commented Feb 2, 2017

Hey @snsavage sorry this sat for so long - if you add a couple tests here and format the comment documentation to match the others I'll merge it in.

end

# Create and assign new access token from extracted token. To be used with
# extract_token to reauthorize app without api call.

This comment has been minimized.

Copy link
@aaronklaassen

aaronklaassen Feb 2, 2017

Member

Could use a @param comment here, for example.

@snsavage

This comment has been minimized.

Copy link
Contributor Author

commented Mar 6, 2017

@aaronklaassen Sorry for the delay. I added some better documentation and some specs. Let me know if this is what you needed. Thanks!

@aaronklaassen aaronklaassen merged commit 267f120 into unsplash:master Mar 6, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls First build on master at 100.0%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.