<commit_before>[Back to Main README](../README.md)

# Full GitHub Authorization in Ember Octane with `torii-provider`

This repository provides a minimal [Ember
Octane](https://emberjs.com/editions/octane/) application for authentication
and authorization with GitHub. It uses
[`ember-simple-auth`](http://github.com/simplabs/ember-simple-auth) and
[`torii`](http://github.com/Vestorly/torii) to provide the authentication and authorization.

This guide is an update and reworking of [the guide provided by
`ember-simple-auth`](https://github.com/simplabs/ember-simple-auth/blob/master/guides/auth-torii-with-github.md),
but it uses Octane syntax and eschews jQuery. It also uses a production-ready
gatekeeper server instead of an `http-mock` server to provide the token
exchange. 

The [basic flow of authenticating with
GitHub](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)
deserves an outline that is personalized for Ember:

1. When the user clicks the login button, the Ember application contacts
   `https://github.com/login/oauth/authorize` with your app’s `client_id`.
   GitHub presents a new window asking the user to authorize access to their
   GitHub account from your app. The user grants this.
2. GitHub redirects back to your app with an `authorizationCode`. This is
   proof of authorization, but your app still doesn’t know _who_ the user is
   (so it cannot connect to a `User` model, for example).
3. Your app sends the `authorizationCode` to a gatekeeper server you maintain,
   which in turn `POST`s the code to
   `https://github.com/login/oauth/access_token`. In development, this can be
   mocked. In production, it must be a separate server, about which more
   below, as we will use a separate server throughout.
4. GitHub responds to the `POST` with an `access_token`, which your gatekeeper
   server forwards to your app.
5. Your app uses the `access_token` in an `Authorization: Bearer<commit_msg>Remember that the guide isn't the README for a different repo.<commit_after>[Back to Main README](../README.md)

# Full GitHub Authorization in Ember Octane with `torii-provider`

This guide is an update and reworking of [the guide provided by
`ember-simple-auth`](https://github.com/simplabs/ember-simple-auth/blob/master/guides/auth-torii-with-github.md),
but it uses Octane syntax and eschews jQuery. It also uses a production-ready
gatekeeper server instead of an `http-mock` server to provide the token
exchange. 

The [basic flow of authenticating with
GitHub](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)
deserves an outline that is personalized for Ember:

1. When the user clicks the login button, the Ember application contacts
   `https://github.com/login/oauth/authorize` with your app’s `client_id`.
   GitHub presents a new window asking the user to authorize access to their
   GitHub account from your app. The user grants this.
2. GitHub redirects back to your app with an `authorizationCode`. This is
   proof of authorization, but your app still doesn’t know _who_ the user is
   (so it cannot connect to a `User` model, for example).
3. Your app sends the `authorizationCode` to a gatekeeper server you maintain,
   which in turn `POST`s the code to
   `https://github.com/login/oauth/access_token`. In development, this can be
   mocked. In production, it must be a separate server, about which more
   below, as we will use a separate server throughout.
4. GitHub responds to the `POST` with an `access_token`, which your gatekeeper
   server forwards to your app.
5. Your app uses the `access_token` in an `Authorization: Bearer
{'fraction_non_alphanumeric': 0.08148148148148149, 'fraction_numerical': 0.0027434842249657062, 'mean_word_length': 4.346041055718475, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5817171', 'n_tokens_mistral': 1047, 'n_tokens_neox': 1012, 'n_words': 460}