使用门卫POST请求oauth2

时间:2014-03-20 13:52:48

标签: api ruby-on-rails-4 oauth-2.0 doorkeeper oauth2client

我正在尝试使用门卫向提供商发送帖子请求。我创建了应用程序和令牌,我对api的获取请求完美无缺:

access_token.get("/api/v1/groups")

但帖子给了我一个很长的错误,包括InvalidAuthenticityToken错误。

access_token.post("/api/v1/groups", params: {group: {title: "Title 1"}})

我在此处发布了错误post request error link

这是我的控制者:

module Api
module V1
    class GroupsController < BaseController
        doorkeeper_for :all

        def index
            render json: current_user.groups
        end

        def create
            render json: current_user.groups.create(group_params)
        end

        private
        def group_params
            params.require(:group).permit(:title, :description, :header_image, :privatization, :amount, :currency, :rate, :max_paiment)
        end
    end
end
end

非常感谢任何反馈,谢谢!

1 个答案:

答案 0 :(得分:1)

protect_from_forgery with: :null_session放入控制器应解决问题

相关问题