-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from Jesus/refresh-access-tokens
Refresh access tokens
- Loading branch information
Showing
16 changed files
with
689 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
module DropboxApi | ||
describe Authenticator do | ||
before :each do | ||
# These details belong to an account I manually created for testing | ||
client_id = "CLIENT_ID" | ||
client_secret = "CLIENT_SECRET" | ||
|
||
@authenticator = DropboxApi::Authenticator.new(client_id, client_secret) | ||
end | ||
|
||
it 'successfully generates a short lived token', cassette: 'authenticator/success_with_short_lived_token' do | ||
# At this point we could get an authorization URL with: | ||
# `@authenticator.auth_code.authorize_url` # => 'https://www.dropbox...' | ||
|
||
# The URL above gave us the following access code: | ||
access_code = "ACCESS_CODEhVAVTMlCvO0Qs" | ||
|
||
access_token = @authenticator.auth_code.get_token(access_code) | ||
|
||
expect(access_token).to be_a(OAuth2::AccessToken) | ||
expect(access_token.token).to eq("MOCK_ACCESS_TOKEN") | ||
expect(access_token.refresh_token).to be_nil | ||
end | ||
|
||
it 'successfully generates a refresh token', cassette: 'authenticator/success_with_refresh_token' do | ||
# We now get an authorization URL with: | ||
# `@authenticator.auth_code.authorize_url(token_access_type: 'offline')` | ||
|
||
# We got the following access code: | ||
access_code = "ACCESS_CODEpLfs_y4vgnb3M" | ||
|
||
access_token = @authenticator.auth_code.get_token(access_code) | ||
|
||
expect(access_token).to be_a(OAuth2::AccessToken) | ||
expect(access_token.token).to eq("MOCK_ACCESS_TOKEN") | ||
expect(access_token.refresh_token).to eq("MOCK_REFRESH_TOKEN") | ||
end | ||
end | ||
end |
Oops, something went wrong.