質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

Q&A

解決済

1回答

2874閲覧

rails4 doorkeeperとdevise でユーザー認証の実装:token返せないです!

shuzootani

総合スコア28

Devise

Deviseとは、Ruby-on-Railsの認証機能を追加するプラグインです。

0グッド

0クリップ

投稿2016/10/08 10:53

編集2016/10/08 11:16

iosアプリ用のAPIを作成していて、rails4 devise doorkeeperでユーザー認証を実装しようとしているんですが、アクセストークンの発行がうまくいかずはまっております。

postmanでAPIを叩くと

"error": "unsupported_grant_type", "error_description": "The authorization grant type is not supported by the authorization server."

と言うエラーを返してくれるんですが、解決の糸口が見えず、困っています!
どなたかご存知の方教えていただけないでしょうか?

Started POST "/oauth/token" for ::1 at 2016-10-08 19:42:06 +0900 ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations" Processing by Doorkeeper::TokensController#create as */* Parameters: {"grant_type"=>"password", "password"=>"[FILTERED]", "email"=>"sample@gmail.com"} Completed 401 Unauthorized in 39ms
[18] pry(main)> access_token = client.password.get_token('sample@gmail.com', 'password') OAuth2::Error: unsupported_grant_type: The authorization grant type is not supported by the authorization server. {"error":"unsupported_grant_type","error_description":"The authorization grant type is not supported by the authorization server."}

initializer/doorkeeper.rb

resource_owner_authenticator do current_user || warden.authenticate!(scope: :user) end Doorkeeper.configuration.token_grant_types << "password"

おそらく下記のようなエラーが出るのでdookeeper.rbのコードが間違ってると思うんですが、

Resource Owner Password Credentials flow failed due to Doorkeeper.configure.resource_owner_from_credentials being unconfigured.

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

doorkeeper.rbの
grant_flows %w(implicit password)の不要な部分を削ると実装できました!

投稿2016/10/08 11:30

shuzootani

総合スコア28

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問