Skip to content

Commit

Permalink
docs: Update oauth docs (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-klasson committed Jul 11, 2024
1 parent 5d4f20b commit 58ee13a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
22 changes: 21 additions & 1 deletion documentation/tutorials/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ defmodule MyApp.Accounts.User do
argument :user_info, :map, allow_nil?: false
argument :oauth_tokens, :map, allow_nil?: false
upsert? true
upsert_identity :email
upsert_identity :unique_email

# Required if you have token generation enabled.
change AshAuthentication.GenerateTokenChange
Expand All @@ -137,3 +137,23 @@ defmodule MyApp.Accounts.User do

end
```

Ensure you set the `hashed_password` to `allow_nil?` if you are also using the password strategy.

```elixir
defmodule MyApp.Accounts.User do
# ...
attributes do
# ...
attribute :hashed_password, :string, allow_nil?: true, sensitive?: true
end
# ...
end
```

And generate and run migrations in that case.

```bash
mix ash.codegen make_hashed_password_nullable
mix ash.migrate
```
23 changes: 22 additions & 1 deletion documentation/tutorials/google.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ First you'll need a registered application in [Google Cloud](https://console.clo
1. On the Cloud's console **Quick access** section select **APIs & Services**, then **Credentials**
2. Click on **+ CREATE CREDENTIALS** and from the dropdown select **OAuth client ID**
3. From the google developers console, we will need: `client_id` & `client_secret`
4. Enter your callback uri under **Authorized redirect URIs**. E.g. `http://localhost:4000/auth/user/google/callback`.

Next we configure our resource to use google credentials:

Expand Down Expand Up @@ -47,7 +48,7 @@ defmodule MyApp.Accounts.User do
argument :user_info, :map, allow_nil?: false
argument :oauth_tokens, :map, allow_nil?: false
upsert? true
upsert_identity :email
upsert_identity :unique_email

change AshAuthentication.GenerateTokenChange

Expand All @@ -66,3 +67,23 @@ defmodule MyApp.Accounts.User do

end
```

Ensure you set the `hashed_password` to `allow_nil?` if you are also using the password strategy.

```elixir
defmodule MyApp.Accounts.User do
# ...
attributes do
# ...
attribute :hashed_password, :string, allow_nil?: true, sensitive?: true
end
# ...
end
```

And generate and run migrations in that case.

```bash
mix ash.codegen make_hashed_password_nullable
mix ash.migrate
```

0 comments on commit 58ee13a

Please sign in to comment.