TrimAgency / bot-starter

0 stars 0 forks source link

Debug OAuth #3

Open sgilliam15 opened 4 years ago

sgilliam15 commented 4 years ago

'/install/auth' and '/install/' Endpoints are not working correctly. We will need to fix this in order to implement the bot in multiple workspaces

controller.webserver.get(
    '/install/auth',
    async (req: Request, res: Response) => {
      console.log('req', req);
      try {
        const results = await controller.adapter.validateOauthCode(
          req.query.code
        );

        console.log('FULL OAUTH DETAILS', results);

        // Store token by team in bot state.
        storage.write({
          [results.team_id]: {
            bot_access_token: results.bot.bot_access_token,
            bot_user_id: results.bot.bot_user_id,
          },
        });

        res.json('Success! Bot installed.');
      } catch (err) {
        console.error('OAUTH ERROR:', err);
        res.status(401);
        res.send(err.message);
      }
    }
  );
StephRicardo commented 4 years ago

To fix this checkout the code in the Sprint bot