Guest User

Untitled

a guest
Feb 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. actionMap.set('input.welcome', DefaultWelcomeIntent);
  2. actionMap.set('sign.in', signIn);
  3.  
  4. function DefaultWelcomeIntent() {
  5. app.askForSignIn();
  6. }
  7.  
  8. function signIn(app) {
  9. if (app.getSignInStatus() === app.SignInStatus.OK) {
  10. let accessToken = app.getUser().accessToken;
  11. app.ask('Great, thanks for signing in!');
  12. } else {
  13. app.ask('I won't be able to save your data, but let's continue!');
  14. }
  15. }
  16.  
  17. app.get('/auth', (req, res) => {
  18.  
  19. var clientID = Hello123ClientID
  20. var redirectURL = 'https://oauth-redirect.googleusercontent.com/r/sampleproject'
  21. var projectID = 'sampleproject'
  22. var ACCESS_TOKEN = 'SampleTokenXXXXXX'
  23. var STATE_STRING;
  24.  
  25. if (req.query.client_id) {
  26. if (req.query.client_id != clientID) {
  27. res.status(503).send("Incorrect ClientID");
  28. }
  29. }
  30. if (req.query.redirect_uri) {
  31. if (req.query.redirect_uri != redirectURL) {
  32. res.status(503).send("Incorrect Re-directURL")
  33. }
  34. }
  35. if (req.query.response_type) {
  36. if (req.query.response_type != 'token') {
  37. res.status(503).send("Incorrect Response_type")
  38. }
  39. }
  40.  
  41. if (req.query.state) {
  42. STATE_STRING = req.query.state
  43. }
  44. var responseoAuthURL ;
  45. responseoAuthURL = 'https://oauth-redirect.googleusercontent.com/r/' + projectID + '#access_token=' + ACCESS_TOKEN + '&token_type=bearer&state=' + STATE_STRING
  46. res.redirect(responseoAuthURL)
  47. });
Add Comment
Please, Sign In to add comment