{"id":17809149,"url":"https://github.com/amareshsm/survey-monkey-oauth","last_synced_at":"2025-04-02T06:26:06.201Z","repository":{"id":57374985,"uuid":"332278115","full_name":"amareshsm/survey-monkey-oauth","owner":"amareshsm","description":"Oauth2 authentication tool for SurveyMonkey","archived":false,"fork":false,"pushed_at":"2021-01-30T18:19:17.000Z","size":213,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T14:39:01.543Z","etag":null,"topics":["surveymonkey","surveymonkey-api","surveymonkey-auth","surveymonkey-oauth"],"latest_commit_sha":null,"homepage":"https://github.com/amareshsm/survey-monkey-oauth","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amareshsm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-23T18:17:39.000Z","updated_at":"2021-01-30T18:19:19.000Z","dependencies_parsed_at":"2022-09-05T13:21:04.521Z","dependency_job_id":null,"html_url":"https://github.com/amareshsm/survey-monkey-oauth","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amareshsm%2Fsurvey-monkey-oauth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amareshsm%2Fsurvey-monkey-oauth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amareshsm%2Fsurvey-monkey-oauth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amareshsm%2Fsurvey-monkey-oauth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amareshsm","download_url":"https://codeload.github.com/amareshsm/survey-monkey-oauth/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246765507,"owners_count":20830118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["surveymonkey","surveymonkey-api","surveymonkey-auth","surveymonkey-oauth"],"created_at":"2024-10-27T15:14:58.883Z","updated_at":"2025-04-02T06:26:06.181Z","avatar_url":"https://github.com/amareshsm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg)](https://opensource.org/licenses/ISC) \n[![1.0](https://badge.fury.io/js/survey-monkey-streams.svg)](//npmjs.com/package/react-js-css-loaders)\n[![Build Status](https://travis-ci.org/amareshsm/survey-monkey-oauth.svg?branch=master)](https://travis-ci.org/amareshsm/survey-monkey-oauth)\n\n# SurveyMonkey oauth #\nOauth2 authentication tools for SurveyMonkey\n## Quick overview ##\n### Step 1: Configuration setup ###\n```\nconst lib = require('survey-monkey-oauth')({\n  clientId: process.env.clientId,\n  clientSecret: process.env.clientSecret,\n  baseURL: 'http://localhost:3000/', /* optional, default baseURL is http://localhost:3000/ */\n  redirectPath: '/callback/',  /* optional, default redirectPath is /callback/ */\n  scope: 'scopes',\n})\n```\n### Step 2: Routes configuration ###\n```\n  if (req.url.match(/login/)) return lib.authorize(req, res)\n  if (req.url.match(/callback/)) return lib.generateToken(req, res)\n```\n\n### Step 3: Listening for response ###\n```\n// on success\nlib.on('success', (tokenRes, res) =\u003e {\n  console.log('success !!!', tokenRes.data)\n  res.end('token successfully generated')\n})\n\n// on failure\nlib.on('error', (errorRes, res) =\u003e {\n  console.log('error', errorRes)\n})\n```\n### Usage ###  \n#### [Using native-addons](https://github.com/amareshsm/survey-monkey-oauth/tree/master/demo/native-api) ####\n```\nconst http = require('http')\nconst port = 3000\nconst hostname = '127.0.0.1'\nconst lib = require('survey-monkey-oauth')({\n  clientId: process.env.clientId,\n  clientSecret: process.env.clientSecret,\n  baseURL: 'http://localhost:3000/',  /* redirect url base */\n  redirectPath: '/callback/', /* redirect url pathname */\n  scope: '',  /* scopes to request permissions from app users during OAuth */\n})\n/* on success */\nlib.on('success', (tokenRes, res) =\u003e {\n  console.log('success !!!', tokenRes.data)\n  res.end('token successfully generated')\n})\n\n/* on failure */\nlib.on('error', (errorRes, res) =\u003e {\n  console.log('error', errorRes)\n})\n\nconst server = http.createServer((req, res) =\u003e {\n  res.statusCode = 200\n  res.setHeader('Content-Type', 'text/plain')\n  if (req.url.match(/login/)) return lib.authorize(req, res) /* /login - initiates oauth authentication */\n  if (req.url.match(/callback/)) return lib.generateToken(req, res) /* /callback - initiates authorization process */\n})\n\nserver.listen(port, hostname, () =\u003e {\n  console.log(`Server running at http://${hostname}:${port}/`)\n})\n```\n##### ***Note: redirectPath and callback route which initiates authorization process must be the same*** #####\n#### [Using express](https://github.com/amareshsm/survey-monkey-oauth/tree/master/demo/express-framework)  ####\n```\nconst express = require('express')\nconst app = express()\nconst port = 3000\nconst lib = require('survey-monkey-oauth')({\n  clientId: process.env.clientId,\n  clientSecret: process.env.clientSecret,\n  baseURL: 'http://localhost:3000/',  /* redirect url base */\n  redirectPath: '/callback/', /* redirect url pathname */\n  scope: '',  /* scopes to request permissions from app users during OAuth */\n})\n\n// on success\nlib.on('success', (tokenRes, res) =\u003e {\n  console.log('success', tokenRes.data)\n  res.end('token successfully generated')\n})\n\n// on failure\nlib.on('error', (errorRes, res) =\u003e {\n  console.log('error', errorRes)\n})\n\napp.get('/', (req, res) =\u003e {\n  res.send('Hello World!')\n})\napp.get('/login/', (req, res) =\u003e {\n  lib.authorize(req, res)  /* /login - initiates oauth authentication */\n})\napp.get('/callback/', (req, res) =\u003e {\n  lib.generateToken(req, res)   /* /callback - initiates authorization process */\n})\napp.listen(port, () =\u003e {\n  console.log(`Example app listening at http://localhost:${port}`)\n})\n```\n### samples available under `/demo` : ###\n\n*  [using-node-native-addons](https://github.com/amareshsm/survey-monkey-oauth/tree/master/demo/native-api)\n*  [using-express-framework](https://github.com/amareshsm/survey-monkey-oauth/tree/master/demo/express-framework) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famareshsm%2Fsurvey-monkey-oauth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famareshsm%2Fsurvey-monkey-oauth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famareshsm%2Fsurvey-monkey-oauth/lists"}