Browse Source

调整Bot授权接口

pull/342/head
xxq250 3 years ago
parent
commit
3d0fa0d50c
1 changed files with 8 additions and 9 deletions
  1. +8
    -9
      app/controllers/installations_controller.rb

+ 8
- 9
app/controllers/installations_controller.rb 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



Loading…
Cancel
Save