doorkeeper-gem / doorkeeper-devise-client Goto Github PK
View Code? Open in Web Editor NEWAn example OAuth 2 client for Doorkeeper Provider App using Rails and Devise
Home Page: https://doorkeeper-devise-client.herokuapp.com
An example OAuth 2 client for Doorkeeper Provider App using Rails and Devise
Home Page: https://doorkeeper-devise-client.herokuapp.com
Let's say I protected a method of my app with doorkeeper_for :create, scopes: [:write]
.
So when the client is asking for authorization, it needs to ask for this scope. How should I do that?
Thanks
Last week's dependabot upgrade broke the build:
------
> [6/8] RUN bundle install --jobs 4:
#0 3.278 Fetching gem metadata from https://rubygems.org/.........
#0 5.886 sqlite3-1.6.3-x86_64-linux requires ruby version >= 2.7, < 3.3.dev, which is
#0 5.886 incompatible with the current version, ruby 2.6.3p62
------
Dockerfile:12
--------------------
10 | COPY Gemfile Gemfile.lock ./
11 |
12 | >>> RUN bundle install --jobs 4
13 |
14 | COPY . .
--------------------
ERROR: failed to solve: process "/bin/sh -c bundle install --jobs 4" did not complete successfully: exit code: 5
Do you have an example where the client is API and will use the provider app for authentication and authorization using the password flow?
Hi
I am using doorkeeper gem and for testing purpose I am using http://doorkeeper-provider.herokuapp.com and http://doorkeeper-devise.herokuapp.com. Once I logged in and clicked on sign out button it returns me to home url.
But if I click on sign in button again, it lands me to user area of http://doorkeeper-devise.herokuapp.com where I can call API's for credentials and profiles, WITHOUT ASKING FOR LOGIN AGAIN.
I am using your doorkeeper gem in my app so please revert m ASAP so that I can test it with client also.
Regards
Is there a way to get the rolify roles from the authorization server to doorkeeper client users table after successful authorization of client app from provider app?
I'm gettting this error after signin in with oauth2 provider, in /users/auth/doorkeeper/callback
:
undefined method `new_session_path' for #<Users::OmniauthCallbacksController:0x000000042d2978>
I've followed some tricks in heartcombo/devise#1390 with no success.
Any idea?
I started doorkeeper-provider-app on port 3000 and doorkeeper-devise-client on port 4000.
http://localhost:3000/oauth/applications/1 screen is :
I click on Authorize button and get the following screen
I click again on Authorize to go to client root
Now, I click on the button "Sign in with Outh2 provider" and get error message
My client side .env file has provider side credentials as follows:
So, is there an error in my re_direct uri?
Dear good people..
I've been struggling to solve this issue the past few days..
PROVIDER (I made it by myself)
according to gem list:
I only use gem 'doorkeeper' and 'devise' in my gemfile
CLIENT (pulling from https://github.com/doorkeeper-gem/doorkeeper-devise-client)
according to gem list
========================================================================
So I click this 'sign in with oauth2 provider' on my doorkeeper-devise-client
and then it redirect me to
http://localhost:3000/users/sign_in?return_to=%2Foauth%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3De1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4000%252Fusers%252Fauth%252Fdoorkeeper%252Fcallback
because I haven't log in to my provider yet..
Here is my provider doorkeeper.rb -> config/initializers/doorkeeper.rb
And then after I login, it redirected me to
http://localhost:4000/users/auth/doorkeeper/callback?code=ea6096403e07e657cae1cedb28e5b72ef69783b14ee17ab56fd2102aabe4868d
with error like this
undefined local variable or method `new_user_session_path' for #Users::OmniauthCallbacksController:0x0055f3bb2ad758
the weird thing is if I use 'https://github.com/doorkeeper-gem/doorkeeper-provider-app' as my provider everything work well..
I should be login to the doorkeeper-devise-client
Here are the log in case you need it
PROVIDER
Started GET "/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback" for 127.0.0.1 at 2018-11-14 10:16:19 +0700
(0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by Doorkeeper::AuthorizationsController#new as HTML
Parameters: {"response_type"=>"code", "client_id"=>"e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0", "redirect_uri"=>"http://localhost:4000/users/auth/doorkeeper/callback"}
Redirected to http://localhost:3000/users/sign_in?return_to=%2Foauth%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3De1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4000%252Fusers%252Fauth%252Fdoorkeeper%252Fcallback
Filter chain halted as :authenticate_resource_owner! rendered or redirected
Completed 302 Found in 10ms (ActiveRecord: 0.0ms)
Started GET "/users/sign_in?return_to=%2Foauth%2Fauthorize%3Fresponse_type%3Dcode%26client_id%3De1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0%26redirect_uri%3Dhttp%253A%252F%252Flocalhost%253A4000%252Fusers%252Fauth%252Fdoorkeeper%252Fcallback" for 127.0.0.1 at 2018-11-14 10:16:19 +0700
Processing by Devise::SessionsController#new as HTML
Parameters: {"return_to"=>"/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback"}
Rendering devise/sessions/new.html.erb within layouts/application
Rendered devise/shared/_links.html.erb (2.2ms)
Rendered devise/sessions/new.html.erb within layouts/application (160.3ms)
Completed 200 OK in 1312ms (Views: 1302.5ms | ActiveRecord: 0.9ms)
Started POST "/users/sign_in" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"โ", "authenticity_token"=>"Ss52g6c+ohz2P2j8+AXy8qKOEHC5QKLxbg4H+JkzXaytPfQwfVd0m7rOKgNJ3/6mJmr5Ya7RSGkcO2hg1mN69w==", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Log in"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? ORDER BY "users"."id" ASC LIMIT ? [["email", "[email protected]"], ["LIMIT", 1]]
Redirected to http://localhost:3000/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback
Completed 302 Found in 359ms (ActiveRecord: 0.4ms)
Started GET "/oauth/authorize?response_type=code&client_id=e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0&redirect_uri=http%3A%2F%2Flocalhost%3A4000%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Doorkeeper::AuthorizationsController#new as HTML
Parameters: {"response_type"=>"code", "client_id"=>"e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0", "redirect_uri"=>"http://localhost:4000/users/auth/doorkeeper/callback"}
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ? [["id", 2], ["LIMIT", 1]]
Doorkeeper::Application Load (0.3ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."uid" = ? LIMIT ? [["uid", "e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0"], ["LIMIT", 1]]
Doorkeeper::AccessToken Load (0.4ms) SELECT "oauth_access_tokens".* FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."application_id" = ? AND "oauth_access_tokens"."resource_owner_id" = ? AND "oauth_access_tokens"."revoked_at" IS NULL ORDER BY "oauth_access_tokens"."created_at" DESC [["application_id", 2], ["resource_owner_id", 2]]
(0.1ms) begin transaction
Doorkeeper::AccessGrant Exists (0.2ms) SELECT 1 AS one FROM "oauth_access_grants" WHERE "oauth_access_grants"."token" = ? LIMIT ? [["token", "ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"], ["LIMIT", 1]]
SQL (0.3ms) INSERT INTO "oauth_access_grants" ("resource_owner_id", "application_id", "token", "expires_in", "redirect_uri", "created_at", "scopes") VALUES (?, ?, ?, ?, ?, ?, ?) [["resource_owner_id", 2], ["application_id", 2], ["token", "ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"], ["expires_in", 600], ["redirect_uri", "http://localhost:4000/users/auth/doorkeeper/callback"], ["created_at", "2018-11-14 03:16:30.722657"], ["scopes", ""]]
(63.0ms) commit transaction
Redirected to http://localhost:4000/users/auth/doorkeeper/callback?code=ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc
Completed 302 Found in 103ms (ActiveRecord: 67.1ms)
Started POST "/oauth/token" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Doorkeeper::TokensController#create as /
Parameters: {"grant_type"=>"authorization_code", "code"=>"[FILTERED]", "client_id"=>"e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0", "client_secret"=>"[FILTERED]", "redirect_uri"=>"http://localhost:4000/users/auth/doorkeeper/callback"}
Doorkeeper::AccessGrant Load (0.3ms) SELECT "oauth_access_grants".* FROM "oauth_access_grants" WHERE "oauth_access_grants"."token" = ? LIMIT ? [["token", "ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"], ["LIMIT", 1]]
Doorkeeper::Application Load (0.2ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."uid" = ? LIMIT ? [["uid", "e1135c4a9a8b8e623279f2483ec729284265a6b8a5c695d7416b35a6eb29f7b0"], ["LIMIT", 1]]
(0.1ms) begin transaction
Doorkeeper::AccessGrant Load (0.2ms) SELECT "oauth_access_grants".* FROM "oauth_access_grants" WHERE "oauth_access_grants"."id" = ? LIMIT ? [["id", 64], ["LIMIT", 1]]
SQL (0.3ms) UPDATE "oauth_access_grants" SET "revoked_at" = ? WHERE "oauth_access_grants"."id" = ? [["revoked_at", "2018-11-14 03:16:30.924931"], ["id", 64]]
Doorkeeper::Application Load (0.2ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
CACHE Doorkeeper::Application Load (0.0ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
Doorkeeper::AccessToken Exists (0.2ms) SELECT 1 AS one FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."token" = ? LIMIT ? [["token", "9ae580adf7d24244119fe7696c348a7df6f70d1dc9f2eb679e904b1dddfcbf4a"], ["LIMIT", 1]]
Doorkeeper::AccessToken Exists (0.1ms) SELECT 1 AS one FROM "oauth_access_tokens" WHERE "oauth_access_tokens"."refresh_token" = ? LIMIT ? [["refresh_token", "b75bba568350dff1e4b5254b83d347c0cea11cbb34e196899f22d78b970b9038"], ["LIMIT", 1]]
SQL (0.2ms) INSERT INTO "oauth_access_tokens" ("resource_owner_id", "application_id", "token", "refresh_token", "expires_in", "created_at", "scopes") VALUES (?, ?, ?, ?, ?, ?, ?) [["resource_owner_id", 2], ["application_id", 2], ["token", "9ae580adf7d24244119fe7696c348a7df6f70d1dc9f2eb679e904b1dddfcbf4a"], ["refresh_token", "b75bba568350dff1e4b5254b83d347c0cea11cbb34e196899f22d78b970b9038"], ["expires_in", 7200], ["created_at", "2018-11-14 03:16:30.965406"], ["scopes", ""]]
(106.7ms) commit transaction
Completed 200 OK in 161ms
Started GET "/api/v1/me.json" for 127.0.0.1 at 2018-11-14 10:16:31 +0700
ActionController::RoutingError (No route matches [GET] "/api/v1/me.json"):
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:63:in call' web-console (3.7.0) lib/web_console/middleware.rb:135:in
call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in block in call' web-console (3.7.0) lib/web_console/middleware.rb:20:in
catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in call' actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in
call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in call_app' railties (5.1.6) lib/rails/rack/logger.rb:24:in
block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in block in tagged' activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in
tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in tagged' railties (5.1.6) lib/rails/rack/logger.rb:24:in
call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in call' actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in
call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in call' rack (2.0.6) lib/rack/method_override.rb:22:in
call'
rack (2.0.6) lib/rack/runtime.rb:22:in call' activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in
call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in call' actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in
call'
rack (2.0.6) lib/rack/sendfile.rb:111:in call' railties (5.1.6) lib/rails/engine.rb:522:in
call'
puma (3.12.0) lib/puma/configuration.rb:225:in call' puma (3.12.0) lib/puma/server.rb:658:in
handle_request'
puma (3.12.0) lib/puma/server.rb:472:in process_client' puma (3.12.0) lib/puma/server.rb:332:in
block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
CLIENT
Started GET "/users/auth/doorkeeper/callback?code=ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc" for 127.0.0.1 at 2018-11-14 10:16:30 +0700
Processing by Users::OmniauthCallbacksController#failure as HTML
Parameters: {"code"=>"ba66e584f43faa8b36c3de4323ee5c60f5a0abe193aed6e8b12206d217091acc"}
Completed 500 Internal Server Error in 17ms
NameError (undefined local variable or method new_user_session_path' for #<Users::OmniauthCallbacksController:0x0055d5bd323258>): app/controllers/application_controller.rb:5:in
new_session_path'
Rendered /home/nutrifood/.rvm/gems/ruby-2.1.0@doorkeeper-devise-client/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
Rendered /home/nutrifood/.rvm/gems/ruby-2.1.0@doorkeeper-devise-client/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
Rendered /home/nutrifood/.rvm/gems/ruby-2.1.0@doorkeeper-devise-client/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (13.7ms)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.