Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using inside of a Rails API #55

Closed
brandonmikeska opened this issue Mar 1, 2016 · 10 comments
Closed

Using inside of a Rails API #55

brandonmikeska opened this issue Mar 1, 2016 · 10 comments

Comments

@brandonmikeska
Copy link

Is there an example of this being used inside of a Rails API project? All of the rails api projects just have authenticating the current user.

@brandonmikeska
Copy link
Author

I keep getting a scope error now but I don't see anywhere for me to set the scope.

@mrrobby
Copy link

mrrobby commented Mar 23, 2016

I agree, there needs to be more documentation on this one. I had to search through the code to get something working. I had success with something similar to this:

def signup_with_auth0!(params,user)
   auth0 = Auth0Client.new( :token => Rails.application.secrets.auth0_api_token,
                            :domain => "yourdomain.auth0.com",
                            :api_version => 2)
   auth0.signup(user.email,params[:password],"Your-UserPass-Authentication")
end

Of course, you could start with params[:email], but you may want to do some other checks first.

After, you can follow the v2 link to their API console and generate your token there with the specific tasks you want to accomplish. There's more methods like signup in the endpoints file. Otherwise, you can build your own client and use the endpoints provided and accessible by the token you generate.

@oyeanuj
Copy link

oyeanuj commented Aug 13, 2016

@brandonmikeska @mrrobby Where did you guys end up with this? I am trying to implement it within a rails-api set up and unclear on some of the details. Is there a gist/repo that anyone could share?

@brandonmikeska
Copy link
Author

brandonmikeska commented Aug 22, 2016

@oyeanuj I got a working example but stopped using rails all together and just went with Firebase. If I find time I will try to create a small repo or gists on what I did. It's not too complicated but basically I created a base controller that would check for the token and inherited the base controller on any controller than needed authentication.

I also created an @auth0 object that was available so I didn't have to set it up every time in an action. Pretty basic stuff. Is that what you are looking for? The only thing is that this was awhile ago and I don't know if it still works with the current project API.

@oyeanuj
Copy link

oyeanuj commented Aug 22, 2016

@brandonmikeska Thank you, that was the kind of information I was looking for! If you can provide any sort of gists for what you described, that would be super helpful and make it much easier to start!

@ignaciojonas - any chance that this could be part of the official documentation?

@ignaciojonas
Copy link
Contributor

Hi @oyeanuj, we are currently working on updating all the rails samples. So far we have completed those for a basic rails web app, they are already available here. Sample-02 might help you, although is not exactly aiming to an API Project.

@oyeanuj
Copy link

oyeanuj commented Sep 7, 2016

@ignaciojonas Thanks for the response. The tutorial on that link doesn't seem to work - https://auth0.com/docs/quickstart/webapp/rails/02-custom-login. Is there an updated link for this?

@ignaciojonas
Copy link
Contributor

@oyeanuj It seems that the tutorial is not merged yet. You can take a look to the code here

@oyeanuj
Copy link

oyeanuj commented Sep 14, 2016

@ignaciojonas thanks! not to extend this thread further, but are there any rails one with an example of password-less magic link authentication?

@joshcanhelp
Copy link
Contributor

Just FYI for anyone looking ... we have a quickstart for a Ruby API:

https://auth0.com/docs/quickstart/backend/ruby

... and one for Rails:

https://auth0.com/docs/quickstart/backend/rails

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants