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

Twitter sign in and authorization methods #21

Merged
merged 14 commits into from
Aug 31, 2015

Conversation

omnibs
Copy link
Contributor

@omnibs omnibs commented Aug 29, 2015

I've used the code created by @arjan referenced on Issue #14, adapted it to the extwitter structure and added some tests where things are testable.

As @arjan said, authorization is difficult to test with automation as it requires user interation on the twitter website, so I left the twitter access_token method commented in the tests.

This is my first Elixir PR so I may have made something silly in the few lines of code that were my own. As so I'm open to any suggestions, code or commit cleanups, etc.

I'm also OK with the idea that authorization/authentication/access token logistics could be better off in a separate module in another repo. It's plausible that people doing just twitter sign-in don't necessarily want to add a complete twitter API to their projects.

Oh yeah, I also updated mix.lock to make it build on ERL 18.

@omnibs
Copy link
Contributor Author

omnibs commented Aug 29, 2015

Missed the vcr fixture for the request_token test, but the rate limit exceed test is still failing.

Exvcr is not detecting the custom cassette for https://api.twitter.com/1.1/followers/ids.json. A bug in exvcr maybe?

Also, cool thing these custom cassettes, I can use one to make the access_token method testable :)

@omnibs
Copy link
Contributor Author

omnibs commented Aug 29, 2015

Alright, it seems exvcr's custom: true flag makes fixtures strict about query string matching.

I thought that might be a bug, so I updated the dependencies.

Turned out it wasn't, so I made the custom fixture take regex urls and fixed it.

All tests are passing but hackney is blowing up for some reason. Could it be the updated dependencies? Will investigate further (help or input is welcome).

@omnibs
Copy link
Contributor Author

omnibs commented Aug 29, 2015

Yay, all tests passing =]

Looks like there was a problem with SSL and 17.3, something in the coveralls script was blowing up due to that. Thank goodness there was a clue in hackney's README.md.


## Reference
https://dev.twitter.com/web/sign-in/implementing
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@parroty
Copy link
Owner

parroty commented Aug 30, 2015

Thanks for the PR! I put some comments in the code, I appreciate if you could check.

I'm thinking it's good to have example sequence in somewhere (readme or wiki). I could confirm the minimal behavior in the following, but if you have other example sequence (ex. callback case), I appreciate if you could share them!

token = ExTwitter.request_token()

{:ok, authorize_url} = ExTwitter.authorize_url(token.oauth_token)

IO.puts authorize_url
# Open browser and authorize to retrieve verifier (pincode)
pincode = "999999"

access_token = ExTwitter.access_token(pincode, token.oauth_token)

Extwitter.configure(
  consumer_key: System.get_env("TWITTER_CONSUMER_KEY"),
  consumer_secret: System.get_env("TWITTER_CONSUMER_SECRET"),
  access_token: access_token.oauth_token,
  access_token_secret: access_token.oauth_token_secret
)

ExTwitter.user_timeline

@omnibs
Copy link
Contributor Author

omnibs commented Aug 30, 2015

Hey parroty, check out the changes.

Tuples, maps and structs were still kinda weird for me when I did this. Thanks for pointing out that specs thing =]

Any more comments?

parroty added a commit that referenced this pull request Aug 31, 2015
Twitter sign in and authorization methods
@parroty parroty merged commit 5be43d0 into parroty:master Aug 31, 2015
@parroty
Copy link
Owner

parroty commented Aug 31, 2015

Thanks for the extensive work!

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

Successfully merging this pull request may close these issues.

2 participants