调整Bot授权接口

This commit is contained in:
xxq250 2023-02-16 11:01:21 +08:00
parent 3c51d69555
commit 3d0fa0d50c
1 changed files with 8 additions and 9 deletions

View File

@ -51,15 +51,14 @@ class InstallationsController < ApplicationController
@install_bot = BotInstall.find params[:id]
@bot = @install_bot.bot
@application = Doorkeeper::Application.find_by(uid: @bot.client_id, secret: @bot.client_secret)
if @application.present?
# 给bot生成token因为bot是机器人操作
@access_token = Doorkeeper::AccessToken.create!({ :application_id => @application.id,
:resource_owner_id => @bot.uid,
:scopes => "public write",
:expires_in => "604800",
:use_refresh_token => true
})
end
tip_exception("该Bot未激活") if @application.blank?
# 给bot生成token因为bot是机器人操作
@access_token = Doorkeeper::AccessToken.create!({ :application_id => @application.id,
:resource_owner_id => @bot.uid,
:scopes => "public write",
:expires_in => "604800",
:use_refresh_token => true
})
render_ok(token: @access_token.token)
end