Skip to main content

Doorkeeper Omniauth OAuth Client Discussion

General • Asked by Chris Oliver

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. https://github.com/gorails-screencasts/oauth-api-authentication

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.


After I click "Authorize" it never makes it to the byebug and I get the following error:

undefined method `[]' for nil:NilClass

uid { raw_info["id"] }

Hello, after I click "Authorize" it never makes it to the byebug and I get the following error:

undefined method `[]' for nil:NilClass

uid { raw_info["id"] }

This happens inside the doorkept-client app and is referring to the omniauth-doorkept gem we made, specifically the file doorkept.rb on line 16.


Comments are not working for me! :(


@17:32

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"
end

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: https://github.com/gorails-screencasts/oauth-api-authentication/blob/master/rails-oauth-provider-app/app/controllers/api/v1/tweets_controller.rb

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
undefined method `provider' for nil:NilClass
Extracted source (around line #47):
45
46
47
48
49
50

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

def titleize

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 20,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.