Rails : Omniauth : Doorkeeper : skip the authorization step

Its simple using doorkeeper to allow some trusted client/apps to allow access without manual acceptance. It helps you to connect two applications seamlessly.

 

# In initializers/doorkeeper.rb
# Under some circumstances you might want to have applications auto-approved,
# so that the user skips the authorization step.
# For example if dealing with a trusted application.
# Example:
#   > client
#    => #<Doorkeeper::OAuth::Client:0x00000006d5f5b0
#     @application=
#       #<Doorkeeper::Application:0x00000006d5fb28
#       id: 1,
#       name: "store",
#       uid: "6ccaad72daa4f60f8a26ad1a7432e895ad12f6ecd816150c4a162b253cd7c2bd",
#       secret: "7e1bfb8e5ddc481021d9ebf445c438537c45734ad04dd51fa3cdeb8d2b5b47f2",
#       redirect_uri: "http://localhost:3001/users/auth/myapp/callback",
#       scopes: "",
#       created_at: Sat, 05 Mar 2016 16:24:56 UTC +00:00,
#       updated_at: Sun, 06 Mar 2016 04:12:01 UTC +00:00>>
#
#   > resource_owner
#   => #<User:0x00000006d56b68
#         id: 4,
#         email: "myemail@gmail.com",
#         encrypted_password: "$2a$10$Jz9aj4gc2fZGPSc2tPYwU.
skip_authorization do |resource_owner, client|
  client.name == 'store'
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s