Authorize a User via command line in Doorkeeper

妖精的绣舞 提交于 2019-12-11 15:09:20

问题


Is it possible to authorize a User for an Application using the Rails console, or even model code?

In certain situations, I want to be able to create and authorize a new user account for a particular application.

Essentially I want to be able generate an authorization_code on the command line.


回答1:


You need to disable the confirmation feature for the app owner:

$ app = Doorkeeper::Application.new :name => 'test', :redirect_uri => 'http://test.com' $ app.owner = User.last # Or any owner class that you want to be associated $ app.save

Take a look on the documentation for further details.




回答2:


Not sure its the best way to do it, but by manually creating a Doorkeeper::AccessGrant, with the proper associations you can get an authorization code from it.



来源:https://stackoverflow.com/questions/16408723/authorize-a-user-via-command-line-in-doorkeeper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!