ruby-on-railsoauth-2.0doorkeeper

How do I create a new application when using Doorkeeper and Rails in api_only mode?


I have a rails 5 api_only app and I'm adding doorkeeper as an Oauth2 provider, also in api_only mode.

When I have api_only mode, I have the following routes added for doorkeeper:

                    Prefix Verb   URI Pattern                                                                              Controller#Action
native_oauth_authorization GET    /oauth/authorize/native(.:format)                                                        doorkeeper/authorizations#show
       oauth_authorization GET    /oauth/authorize(.:format)                                                               doorkeeper/authorizations#new
                           DELETE /oauth/authorize(.:format)                                                               doorkeeper/authorizations#destroy
                           POST   /oauth/authorize(.:format)                                                               doorkeeper/authorizations#create
               oauth_token POST   /oauth/token(.:format)                                                                   doorkeeper/tokens#create
              oauth_revoke POST   /oauth/revoke(.:format)                                                                  doorkeeper/tokens#revoke
          oauth_introspect POST   /oauth/introspect(.:format)                                                              doorkeeper/tokens#introspect
          oauth_token_info GET    /oauth/token/info(.:format)                                                              doorkeeper/token_info#show

None of the routes listed in the API docs for creating applications (to get my client_secret, etc.) are present.

How do I create a new application and get/set my client_id, client_secret, and redirect_uri?


Solution

  • One way I've found (from the Doorkeeper::ApplicationsController) is

    Doorkeeper::Application.create(name: "foobar", redirect_uri: "urn:ietf:wg:oauth:2.0:oob", scopes: ["read", "write"])
    

    the secret, and uid will be securely generated when you save.