earln

earln

Ash Authentication password strategy token error when following Getting Started Guide

Following the Ash Authentication Phoenix Getting Started Guide, I get the following error message when trying to save/compile the user.ex resource:

    ** (Spark.Error.DslError) [nil]
 authentication -> tokens -> enabled?:
  The `:password` authentication strategy requires tokens be enabled.

To fix this error you can either:
  1. disable the `:password` strategy, or
  2. enable tokens.

The authentication section of the user.ex resource is as specified in the guide:

  authentication do
    strategies do
      password :password do
        identity_field :email
      end
    end
    ...
 end

I tried adding “sign_in_tokens_enabled? true” in the password section of authentication. However, they did not work either.

How would I enable the tokens to be able to use the password authentication strategy? Docs say tokens are enabled by default?

I expect I am overlooking something obvious.

Any help would be appreciated. Thanks to everyone for the great work on Ash 3.0.

Most Liked

arcanemachine

arcanemachine

Yeah I ran into that one too. To fix the immediate problem, you just need to add enabled? true in the tokens section:

    tokens do
      enabled? true # Add this line
      token_resource Example.Accounts.Token
      signing_secret Example.Accounts.Secrets
    end

https://github.com/team-alembic/ash_authentication/issues/679

zachdaniel

zachdaniel

Creator of Ash

There have been some changes to this just recently that are likely the cause of the confusion.

authentication do
    tokens do
      token_resource MyApp.Accounts.Token
      signing_secret fn _, _ ->
        Application.fetch_env(:my_app, :token_signing_secret)
      end
    end
end

You need to configure the tokens resource, or set sign_in_tokens_enabled? false.

Make sure to check the very latest version of the docs, and then if you could please open an issue on ash_authentication pointing out the docs that caused confusion and we will address.

webspaceadam

webspaceadam

thanks. you just saved my sunday coding session :slight_smile:

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52341 488
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

We're in Beta

About us Mission Statement