ashkan117

ashkan117

Multiple Strategies for AshAuthentication

I am trying to migrate my current application from only allowing users to sign in with Google Auth, to also be able to create an account with username and password. I want people with just username and password to be able to optionally connect their google accounts in order to sync their calendars.

So I currently have a working setup for register_with_password and register_with_google but I’m a little unsure how I can add the option just to connect a users Google Calendar? Would I need to create another oauth strategy?

      # Current oauth2 for registering
      oauth2 :google do
        ...
        authorization_params(
          access_type: "offline",
          scope:
            "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/calendar"
        )

        identity_resource(MyApp.Accounts.UserIdentity)
      end

  1. Do I need another oauth2 strategy that only needs the google calendar scope?
  2. How do I connect this to my Phoenix/Liveview app

First Post!

kamaroly

kamaroly

  1. I don’t think you need another strategy for google calendar. Google uses centralised authentication for all its products.
  2. After the authentication is successfully, you should be able to access the logged in user via @current_user assign in liveview.

Last Post!

ashkan117

ashkan117

Hello! Thanks for the reply.

Maybe I could explain my problem better. In my case, I show the user a calendar. I’d want that calendar linked to multiple google calendar accounts. So in this case I’d want one user to have many google accounts connected.

Another thing that makes me think I need multiple strategies is that I’d want each account to be flexible and allow for different read/write permissions.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

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
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 54260 488
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement