Skip to main content

Doorkeeper Omniauth OAuth Client Discussion

General • Asked by Chris Oliver
The video freeze between 0:18 and 0:40, not a big deal imo but I wanted to let you know :)
Thanks for the heads up! What a pain in the butt.

After I click "Authorize" it never makes it to the byebug. I get an error that says:

undefined method `[]' for nil:NilClass

uid { raw_info["id"] }

The error is inside "doorkept-client"

It is referring to the omniauth-doorkept gem inside the file doorkept.rb on line 16

Hey Trevor,

That means your raw_info is returning nil. It should be returning an hash {}.

Also I uploaded all the source code for these finally so you can reference my omniauth gem. I think I made some tweaks to it.

Thanks Chris, I fixed it. The problem was my me.json.jbuilder file was in the wrong directory. :)

Would have corrected this last night, but my comment didn't show up.


You did not show the process of creating the tweets.json scaffold... I realize you think you went over enough to have this be obvious but at this point its not, i went through and created all of the files manually you have in your repoistory but am getting

uninitialized constant Api::V1::TweetsController::Tweet
# GET /tweets.json
def index
@tweets = Tweet.all
render "tweets/index"

Correct, I did exactly as I said in the video at that timestamp:

All I did was run the Rails scaffold generator for Tweet rails g scaffold Tweet user:references body:text

Added Api::V1::TweetsController, with doorkeeper authentication and had it render the same views. As seen here:

You say you "created all of the files manually" but it says that the Tweet class is uninitialized. You either didn't create the Tweet model or you have something like Spring caching that hasn't reloaded it.

thank you for your response, I removed the files i had created and ran the scaffold... now just getting this back

Started GET "/api/v1/tweets.json" for ::1 at 2018-10-02 03:37:14 -0400
Processing by Api::V1::TweetsController#index as JSON
Filter chain halted as :doorkeeper_authorize! rendered or redirected
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)

Also having this issue when i try to login from the client to my provider...

No route matches [GET] "/oauth/authorize"
Rails.root: /Users/username/project/my_client

Filter chain halted as :doorkeeper_authorize! rendered or redirected

That means that your API key was not passed over or not valid.

Thanks i did just notice my api key changed and fixed that.

When i run a scaffold i get this error:

(erb):1:in template': undefined local variable or methodmodel_resource_name' for #Erb::Generators::ScaffoldGenerator:0x007fa59de06e48 (NameError)

Please help, this is incredibly confusing...

NoMethodError in Users::OmniauthCallbacksController#doorkept
undefined method `titleize' for :doorkept:Symbol
Extracted source (around line #57):

  elsif User.where(email:
    # 5. User is logged out and they login to a new account which doesn't match their old one
    flash[:alert] = "An account with this email already exists. Please sign in with that account before connecting your #{auth.provider.titleize} account."
    redirect_to new_user_session_path
    @user = create_user

undefined method `provider' for nil:NilClass
Extracted source (around line #47):

def set_service
  @service = Service.where(provider: auth.provider, uid: auth.uid).first

def titleize

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 18,000+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.