Giter Site home page Giter Site logo

rohit-ravikoti / ext-idp-api-webtask Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vikasjayaram/ext-idp-api-webtask

0.0 1.0 0.0 5 KB

Call External IDP API using the user idp access token with read:user_idp_token flow.

JavaScript 100.00%

ext-idp-api-webtask's Introduction

Calling A External IDP API Eg. Google using webtask

Sample project for creating an Express-based server that runs on webtask.io for accessing external IDP api with the user's idp access token.

Version

0.0.1

Initial Setup & Configuration

# Create a new wt-cli profile
npm install -g wt-cli
wt init

# Or, if you already use wt-cli:
wt profile ls

Please read the following link on how to Call an Identity Provider API

Some more resources to read on Identity Provider Access Tokens

Initialization

$ wt create ext_idp_webtask.js
    -s CLIENT_ID=YOUR_NON_INTERACTIVE_AUTH0_CLIENT_ID
    -s CLIENT_SECRET=YOUR_NON_INTERACTIVE_AUTHO_CLIENT_SECRET
    -s ACCOUNT_NAME=YOUR_AUTH0_TENANT_NAME
    -s ID_TOKEN_CLIENT_SECRET=YOUR_CLIENT_SECRET

The above command would create a webtask and give you a url like this

Webtask created

You can access your webtask at the following url:

https://webtask.it.auth0.com/api/run/wt-vikas_ramasethu-gmail_com-0/ext_idp_webtask/call_ext_api?webtask_no_cache=1

Usage

  "use strict";
  const request = require('request');
  const options = {
    url: 'URL_WHEN_YOU_CREATE_WEBTASK',
    headers: {Authorization: 'Bearer USER_ID_TOKEN'},
    json: {api_url: 'IDP_API'}
  };
  request.post(options, function (e, r, b){});

Example Usage

The below is a sample on how to call a Google API with.

  "use strict";

  const request = require('request');
  const options = {
    url: 'https://webtask.it.auth0.com/api/run/wt-vikas_ramasethu-gmail_com-0/ext_idp_webtask/call_ext_api?webtask_no_cache=1',
    headers: {Authorization: 'Bearer USER_ID_TOKEN'},
    json: {api_url: 'https://www.googleapis.com/youtube/v3/channels?part=snippet%2C+id%2C+statistics&mine=true'}
  };
  request.post(options, function (e, r, b){});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.