# \[Video tutorial\] Adding Sign in with Twitter to your Crystal web app

**URL:** <https://forum.crystal-lang.org/t/video-tutorial-adding-sign-in-with-twitter-to-your-crystal-web-app/1718>\
**Category:** Learning Resources\
**Created:** [February 15, 2020, 8:46pm UTC](https://forum.crystal-lang.org/t/video-tutorial-adding-sign-in-with-twitter-to-your-crystal-web-app/1718 "2020-02-15T20:46:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lbarasti](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/lbarasti/32/648_2.png) [@lbarasti](https://forum.crystal-lang.org/u/lbarasti)\
**Post date:** [February 15, 2020, 8:46pm UTC](https://forum.crystal-lang.org/t/video-tutorial-adding-sign-in-with-twitter-to-your-crystal-web-app/1718/1 "2020-02-15T20:46:01Z")

</div>

Hi folks, I just published a tutorial on how to add the _Sign in with Twitter_ functionality to a Crystal web app.

  
The inspiration for the tutorial came from [a shard I wrote](https://github.com/lbarasti/twitter_auth) a while ago to simplify the _3-legged OAuth1.0a_ method. You can read more about that on Twitter’s [official guide](https://developer.twitter.com/en/docs/basics/authentication/guides/log-in-with-twitter).

The code shown in the presentation - a Kemal web app with a Vue.js front end - is available on [github](https://github.com/lbarasti/trimmer), and you can find the slides [here](https://slides.com/lorenzobarasti/sign-in-with-twitter).

While preparing this tutorial, I noticed that it’s hard to find standard practices around the management of third-party OAuth tokens. There also seems to be a lot of variability in the way developers share authentication secrets with the user, once an access token has been obtained.

With this in mind, I hope this topic can be an opportunity to share your experiences with _sign in with X_ integrations 🍿

---

<div class="post-metadata">

**Author:** ![carcinocron](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/carcinocron/32/1022_2.png) [@carcinocron](https://forum.crystal-lang.org/u/carcinocron)\
**Post date:** [February 17, 2020, 2:45pm UTC](https://forum.crystal-lang.org/t/video-tutorial-adding-sign-in-with-twitter-to-your-crystal-web-app/1718/2 "2020-02-17T14:45:26Z")

</div>

Are you thinking to do one for tumblr?

---

<div class="post-metadata">

**Author:** ![lbarasti](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/lbarasti/32/648_2.png) [@lbarasti](https://forum.crystal-lang.org/u/lbarasti)\
**Post date:** [February 17, 2020, 10:58pm UTC](https://forum.crystal-lang.org/t/video-tutorial-adding-sign-in-with-twitter-to-your-crystal-web-app/1718/3 "2020-02-17T22:58:27Z")

</div>

Hey @carcinocron, I hadn’t thought of that, but after a quick look to the Tumblr docs it looks like most of the code in `twitter_auth` should be reusable - except for some Tumblr quirks that seem manageable.

Let me have a closer look and come back to you 🕵️‍♂️

---

<div class="post-metadata">

**Author:** ![lbarasti](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/lbarasti/32/648_2.png) [@lbarasti](https://forum.crystal-lang.org/u/lbarasti)\
**Post date:** [February 23, 2020, 6:33pm UTC](https://forum.crystal-lang.org/t/video-tutorial-adding-sign-in-with-twitter-to-your-crystal-web-app/1718/4 "2020-02-23T18:33:19Z")

</div>

Dear @carcinocron, what a journey this was 🚅

### TL;DR

You’ll find a working **Sign in with Tumblr** example [here](https://github.com/lbarasti/simple_oauth/tree/master/examples/tumblr_integration).

![oauth_flow](https://canada1.discourse-cdn.com/flex036/uploads/crystal_lang/original/1X/c21a762164bca5adaa028d0db7a4bba681996b80.gif)

### More details

Turns our there is a slight difference between Twitter and Tumblr in the way they expect you to sign the access token request.

Twitter expects a signature based on the consumer secret only, whereas Tumblr expects one based on both the consumer secret and the request token secret - AKA the resource owner secret.

Anyhow, I extracted the common functionality in a shard called [simple\_oauth](https://github.com/lbarasti/simple_oauth) - I’ll update `twitter_auth` to depend on that, too.

Finally, a note that this new shard’s capabilities are already part of the [Crystal Standard Library](https://crystal-lang.org/api/latest/OAuth.html).

I see only a couple of reasons to prefer `simple_oauth` to the standard library module:

1. It’s easier to understand and update - by means of being much smaller
2. it makes it easy to swap the HTTP client used in the calls to the OAuth provider.
