调整Bot授权接口
This commit is contained in:
parent
3c51d69555
commit
3d0fa0d50c
|
@ -51,15 +51,14 @@ class InstallationsController < ApplicationController
|
||||||
@install_bot = BotInstall.find params[:id]
|
@install_bot = BotInstall.find params[:id]
|
||||||
@bot = @install_bot.bot
|
@bot = @install_bot.bot
|
||||||
@application = Doorkeeper::Application.find_by(uid: @bot.client_id, secret: @bot.client_secret)
|
@application = Doorkeeper::Application.find_by(uid: @bot.client_id, secret: @bot.client_secret)
|
||||||
if @application.present?
|
tip_exception("该Bot未激活") if @application.blank?
|
||||||
# 给bot生成token,因为bot是机器人操作
|
# 给bot生成token,因为bot是机器人操作
|
||||||
@access_token = Doorkeeper::AccessToken.create!({ :application_id => @application.id,
|
@access_token = Doorkeeper::AccessToken.create!({ :application_id => @application.id,
|
||||||
:resource_owner_id => @bot.uid,
|
:resource_owner_id => @bot.uid,
|
||||||
:scopes => "public write",
|
:scopes => "public write",
|
||||||
:expires_in => "604800",
|
:expires_in => "604800",
|
||||||
:use_refresh_token => true
|
:use_refresh_token => true
|
||||||
})
|
})
|
||||||
end
|
|
||||||
render_ok(token: @access_token.token)
|
render_ok(token: @access_token.token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue