0

I've unsuccessfully scoured the internet for an example of how to authenticate against Google APIs using node and the Bot Framework emulator. I've got as far as calling the Google login but have no idea how to capture the authorisation code back in the bot. I am using the npm module googleapis. The code so far:

 var google = require('googleapis');
 var OAuth2Client = google.auth.OAuth2;
 var plus = google.plus('v1');
 var CLIENT_ID = "xxx.apps.googleusercontent.com";
 var CLIENT_SECRET = "xxx";
 var REDIRECT_URL = 'http://localhost:3978'; // Not sure about this!

 var oauth2Client = new OAuth2Client(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL);
 var url = oauth2Client.generateAuthUrl({
         access_type: 'offline', 
         scope: 'https://www.googleapis.com/auth/drive' 
     });

The url generated takes me to the Google login page. From there, I haven't been able to make any progress. I've tried https://github.com/google/google-api-nodejs-client/blob/master/samples/oauth2.js and a few other examples but none that use the bot framework. I am unclear as to how to retrieve the authentication code in the bot once I allow access on the Google authentication web page. Any guidance is appreciated.

Taz Evans
  • 37
  • 1
  • 7
  • You'd better use pattern with magic codes. Take a look at this: https://stackoverflow.com/questions/42276830/authenticate-user-in-microsoft-bot-framework/42277480#42277480 – Just Shadow Jul 18 '17 at 13:46

1 Answers1

1

I believe the Google authentication will just call your redirect URL, since it's using the OAuth protocol.

You need to create a new endpoint where you will receive the response of the Google Authentication. Similar to what AuthBot for Node.

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43
  • Any idea what the endpoint should be as we're talking about the locally hosted emulator in this case? – Taz Evans Jul 18 '17 at 17:22
  • It doesn't matter if you are using the emulator or something else. the endpoint is something on your code. Is just a new route in your api where you can receive requests – Ezequiel Jadib Jul 18 '17 at 19:25