Skip to content

Commit 7d82d78

Browse files
committed
Merge pull request #5 from ueberauth/doc-updates
Update README format
2 parents 5f36df3 + a3a6797 commit 7d82d78

2 files changed

Lines changed: 73 additions & 88 deletions

File tree

CONTRIBUTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Contributing to Ueberauth GitHub
2+
3+
## Pull Requests Welcome
4+
1. Fork ueberauth_github
5+
2. Create a topic branch
6+
3. Make logically-grouped commits with clear commit messages
7+
4. Push commits to your fork
8+
5. Open a pull request against ueberauth_github/master
9+
10+
## Issues
11+
12+
If you believe there to be a bug, please provide the maintainers with enough
13+
detail to reproduce or a link to an app exhibiting unexpected behavior. For
14+
help, please start with Stack Overflow.

README.md

Lines changed: 59 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,88 @@
11
# Überauth GitHub
22

3-
Provides an Üeberauth strategy for authenticating with Github.
3+
> GitHub OAuth2 strategy for Überauth.
44
5-
### Setup
5+
## Installation
66

7-
Create an application in Github for you to use.
7+
1. Setup your application at [GitHub Developer](https://developer.github.com).
88

9-
Register a new application at: [your github developer page](https://github.com/settings/developers) and get the `client_id` and `client_secret`.
9+
1. Add `:ueberauth_github` to your list of dependencies in `mix.exs`:
1010

11-
Include the provider in your configuration for Üeberauth
11+
```elixir
12+
def deps do
13+
[{:ueberauth_github, "~> 0.1"}]
14+
end
15+
```
1216

13-
````elixir
14-
config :ueberauth, Ueberauth,
15-
providers: [
16-
github: [ { Ueberauth.Strategy.Github, [] } ]
17-
]
18-
````
17+
1. Add the strategy to your applications:
1918

20-
Then include the configuration for github.
19+
```elixir
20+
def application do
21+
[applications: [:ueberauth_github]]
22+
end
23+
```
2124

22-
````elixir
23-
config :ueberauth, Ueberauth.Strategy.Github.OAuth,
24-
client_id: System.get_env("GITHUB_CLIENT_ID"),
25-
client_secret: System.get_env("GITHUB_CLIENT_SECRET")
26-
````
25+
1. Add GitHub to your Überauth configuration:
2726

28-
If you haven't already, create a pipeline and setup routes for your callback handler
27+
```elixir
28+
config :ueberauth, Ueberauth,
29+
providers: [
30+
github: [{Ueberauth.Strategy.GitHub, []}]
31+
]
32+
```
2933

30-
````elixir
31-
pipeline :auth do
32-
Ueberauth.plug "/auth"
33-
end
34+
1. Update your provider configuration:
3435

35-
scope "/auth" do
36-
pipe_through [:browser, :auth]
36+
```elixir
37+
config :ueberauth, Ueberauth.Strategy.GitHub.OAuth,
38+
client_id: System.get_env("GITHUB_CLIENT_ID"),
39+
client_secret: System.get_env("GITHUB_CLIENT_SECRET")
40+
```
3741

38-
get "/:provider/callback", AuthController, :callback
39-
end
40-
````
42+
1. Include the Überauth plug in your controller:
4143

44+
```elixir
45+
defmodule MyApp.AuthController do
46+
use MyApp.Web, :controller
47+
plug Ueberauth
48+
...
49+
end
50+
```
4251

43-
Create an endpoint for the callback where you will handle the `Ueberauth.Auth` struct
52+
1. Create the request and callback routes if you haven't already:
4453
45-
````elixir
46-
defmodule MyApp.AuthController do
47-
use MyApp.Web, :controller
54+
```elixir
55+
scope "/auth", MyApp do
56+
pipe_through :browser
4857
49-
def callback_phase(%{ assigns: %{ ueberauth_failure: fails } } = conn, _params) do
50-
# do things with the failure
51-
end
58+
get "/:provider", AuthController, :request
59+
get "/:provider/callback", AuthController, :callback
60+
end
61+
```
5262
53-
def callback_phase(%{ assigns: %{ ueberauth_auth: auth } } = conn, params) do
54-
# do things with the auth
55-
end
56-
end
57-
````
63+
1. You controller needs to implement callbacks to deal with `Ueberauth.Auth` and `Ueberauth.Failure` responses.
5864
59-
You can edit the behaviour of the Strategy by including some options when you register your provider.
65+
For an example implementation see the [Überauth Example](https://github.com/ueberauth/ueberauth_example) application.
6066
61-
To set the `uid_field`
67+
## Calling
6268
63-
````elixir
64-
config :ueberauth, Ueberauth,
65-
providers: [
66-
github: [ { Ueberauth.Strategy.Github, [uid_field: :email] } ]
67-
]
68-
````
69+
Depending on the configured url you can initial the request through:
70+
71+
/auth/github
6972
70-
Default is `:login`
73+
Or with options:
7174
72-
To set the default 'scopes' (permissions):
75+
/auth/github?scope=user,public_repo
7376
74-
````elixir
77+
By default the requested scope is "user,public_repo". Scope can be configured either explicitly as a `scope` query value on the request path or in your configuration:
78+
79+
```elixir
7580
config :ueberauth, Ueberauth,
7681
providers: [
77-
github: [ { Ueberauth.Strategy.Github, [default_scope: "user,public_repo"] } ]
82+
github: {Ueberauth.Strategy.GitHub, [default_scope: "user,public_repo,notifications"]}
7883
]
79-
````
80-
81-
Deafult is "user,public_repo"
82-
83-
## Installation
84-
85-
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
86-
87-
1. Add ueber_github to your list of dependencies in `mix.exs`:
88-
89-
````elixir
90-
def deps do
91-
[{:ueberauth_github, "~> 0.1.0"}]
92-
end
93-
````
94-
95-
# License
96-
97-
The MIT License (MIT)
98-
99-
Copyright (c) 2015 Daniel Neighman
100-
101-
Permission is hereby granted, free of charge, to any person obtaining a copy
102-
of this software and associated documentation files (the "Software"), to deal
103-
in the Software without restriction, including without limitation the rights
104-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
105-
copies of the Software, and to permit persons to whom the Software is
106-
furnished to do so, subject to the following conditions:
84+
```
10785
108-
The above copyright notice and this permission notice shall be included in all
109-
copies or substantial portions of the Software.
86+
## License
11087
111-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
112-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
113-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
114-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
115-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
116-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
117-
SOFTWARE.
88+
Please see [LICENSE](https://github.com/ueberauth/ueberauth_github/blob/master/LICENSE) for licensing details.

0 commit comments

Comments
 (0)