| @@ -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? | |||||
| # 给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) | render_ok(token: @access_token.token) | ||||
| end | end | ||||