• Stars
    star
    426
  • Rank 101,884 (Top 3 %)
  • Language
    JavaScript
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ”— OAuth 2.0 implementation for various providers in one place.

OAuth

OAuth 2.0 implementation for various providers in one place.

Facebook Google Instagram LinkedIn Twitter Reddit Discord Zoom GitHub GitLab DigitalOcean Bitbucket Azure Spotify Shopify

This project contains OAuth 2.0 implementation for various providers and help you understand following OAuth 2.0 flow:

  1. Show platform dialog
  2. Get Access Token
  3. Use token to fetch user details

Actual steps implemented in this sample code repository:

  1. Create redirect URL for respective platform
  2. Redirect the user to respective platform
  3. User decides to grant the permissions to the application
  4. Receive temporary code on the server
  5. Exchange the temporary code for access token
  6. Get user details using the access token
  7. Save user details into the database and authenticate the user

Although this project is built using React on the front-end and NodeJS on the back-end, the flow and implementation largely remains same for any other language or framework.

OAuth

Integrations

Social platforms

Tech platforms

Other platforms

Docs

Facebook

  1. Read official flow: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
  2. Create a new application: https://developers.facebook.com/apps/
  3. Goto App โ†’ Add Product and choose Facebook Login
  4. Goto App โ†’ Products โ†’ Facebook Login โ†’ Settings and add a Valid OAuth Redirect URI as https://example.com/authorize/ (replace your actual domain for live)
  5. Goto App โ†’ Settings and copy App ID and App Secret
  6. Update web/.env.local REACT_APP_OAUTH_FACEBOOK_ID with App ID
  7. Update api/.env.local OAUTH_FACEBOOK_ID with App ID
  8. Update api/.env.local OAUTH_FACEBOOK_SECRET with App Secret

โ†‘ all integrations


Google

  1. Read official flow: https://developers.google.com/identity/protocols/oauth2/web-server
  2. Create a new application: https://console.cloud.google.com/projectcreate
  3. Setup consent screen https://console.cloud.google.com/apis/credentials/consent
    1. Choose External (Available to any user with a Google Account.)
    2. In Authorized domains input enter example.com
    3. Fill in Application Name and click Save button
  4. Create Credentials https://console.cloud.google.com/apis/credentials
    1. Click on + CREATE CREDENTIALS button
    2. Choose OAuth client ID
    3. Select Web application
    4. For Authorized redirect URIs, fill in following two entries:
      1. https://example.com/authorize/
      2. http://localhost:3000/authorize/
  5. Copy Your Client ID and Your Client Secret
  6. Update web/.env.local REACT_APP_OAUTH_GOOGLE_ID with Your Client ID
  7. Update api/.env.local OAUTH_GOOGLE_ID with Your Client ID
  8. Update api/.env.local OAUTH_GOOGLE_SECRET with Your Client Secret

โ†‘ all integrations


Instagram

  1. Read official flow: https://developers.facebook.com/docs/instagram-basic-display-api/getting-started

  2. Create a new application: https://developers.facebook.com/apps/

  3. Goto App โ†’ Settings โ†’ Basic and fill in all the required fields

  4. Goto App โ†’ Add Product and choose Instagram Basic Display

  5. Click on Create New App button

  6. Goto App โ†’ Products โ†’ Basic Display and fill in following

    1. Valid OAuth Redirect URIs as https://example.com/authorize/
    2. Deauthorize Callback URL as https://example.com/authorize/instagram-deauthorize
    3. Data Deletion Request URL as https://example.com/authorize/instagram-delete
  7. Goto App โ†’ Products โ†’ Basic Display โ†’ Roles โ†’ Roles and click on Add Instagram Testers, search for your account and click on Submit

  8. Accept the tester invite https://www.instagram.com/accounts/manage_access/

  9. Goto App โ†’ Products โ†’ Basic Display and copy Instagram App ID and Instagram App Secret

  10. Update web/.env.local REACT_APP_OAUTH_INSTAGRAM_ID with Instagram App ID

  11. Update api/.env.local OAUTH_INSTAGRAM_ID with Instagram App ID

  12. Update api/.env.local OAUTH_INSTAGRAM_SECRET with Instagram App Secret

  13. Note:

    1. As of writing this Readme, Instagram does not accept localhost:3000 as valid callback URI. So while testing, you may need to manually change the callback URL.
    2. For production, you need to complete App Review for Instagram Basic Display by submitting instagram_graph_user_profile and instagram_graph_user_media for review.

โ†‘ all integrations


LinkedIn

  1. Read official flow: https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow
  2. Create a new application: https://www.linkedin.com/developers/apps/new and fill in following:
    1. App name enter your application name, eg: Example
    2. Company select an existing or create new company page
    3. App logo upload a logo
  3. Click on Create app button
  4. Goto App โ†’ Auth
    1. Under Redirect URLs, fill in following two entries:
      1. http://localhost:3000/authorize/
      2. https://example.com/authorize/
    2. Copy Client ID and Client Secret
  5. Update web/.env.local REACT_APP_OAUTH_LINKEDIN_ID with Client ID
  6. Update api/.env.local OAUTH_LINKEDIN_ID with Client ID
  7. Update api/.env.local OAUTH_LINKEDIN_SECRET with Client Secret

โ†‘ all integrations


Twitter

  1. Read official flow: https://developer.twitter.com/en/docs/authentication/oauth-2-0
  2. Create a new project: https://developer.twitter.com/en/portal/projects-and-apps and fill in following:
    1. Project name enter your project name, eg: Example
    2. Project use select appropriate use-case
  3. Create a new app inside project: https://developer.twitter.com/en/portal/projects/<PROJECT_ID>/apps/create-or-connect and fill in following:
    1. App environment select Development
    2. App name enter your application name, eg: Example
    3. Click on App Setting button
    4. Under User authentication settings on Setup button
    5. Enable OAuth 2.0
    6. Under Callback URI / Redirect URL, fill in following two entries:
      1. http://localhost:3000/authorize/
      2. https://example.com/authorize/
    7. Enter Website URL
    8. Click Save button
  4. Head to Keys and token https://developer.twitter.com/en/portal/projects/<PROJECT_ID>/apps/<APP_ID>/keys OAuth 2.0 Client ID and Client Secret section
    1. Update web/.env.local REACT_APP_OAUTH_TWITTER_ID with Client ID
    2. Update api/.env.local OAUTH_TWITTER_ID with Client ID
    3. Update api/.env.local OAUTH_TWITTER_SECRET with Client Secret

โ†‘ all integrations


Reddit

  1. Read official flow: https://github.com/reddit-archive/reddit/wiki/OAuth2
  2. Create a new OAuth application: https://www.reddit.com/prefs/apps and fill in following:
    1. name enter your application name, eg: Example
    2. description enter info about your app, eg: OAuth example application
    3. about url enter your website url, eg: https://example.com
    4. redirect uri:
      1. For development, enter http://localhost:3000/authorize/
      2. For production, enter https://example.com/authorize/
  3. Click on create app button
  4. Copy id (below the entered app name) and secret
  5. Update web/.env.local REACT_APP_OAUTH_REDDIT_ID with id
  6. Update api/.env.local OAUTH_REDDIT_ID with id
  7. Update api/.env.local OAUTH_REDDIT_SECRET with secret

โ†‘ all integrations


Discord

  1. Read official flow: https://discord.com/developers/docs/topics/oauth2
  2. Create a new OAuth application: https://discord.com/developers/applications and click on New Application
  3. Fill in name, eg: Example and click on Create button
  4. Go to application's OAuth section https://discord.com/developers/applications/CLIENT_ID/oauth2 and for Redirects, create following two entries:
    1. http://localhost:3000/authorize/ for development
    2. https://example.com/authorize/ for production
  5. Copy CLIENT ID (below the entered app name) and CLIENT SECRET
  6. Update web/.env.local REACT_APP_OAUTH_DISCORD_ID with CLIENT ID
  7. Update api/.env.local OAUTH_DISCORD_ID with CLIENT ID
  8. Update api/.env.local OAUTH_DISCORD_SECRET with CLIENT SECRET

โ†‘ all integrations


Zoom

  1. Read official flow: https://marketplace.zoom.us/docs/guides/build/oauth-app
  2. Create a new OAuth application: https://marketplace.zoom.us/develop/create under OAuth click Create button and fill in following:
    1. Name enter your application name, eg: Example
    2. Select User-managed app
  3. Under Redirect URL for OAuth, enter following:
    1. For development, enter http://localhost:3000/authorize/
    2. For production, enter https://example.com/authorize/
  4. Under Whitelist URL, enter following:
    1. For development, enter http://localhost:3000
    2. For production, enter https://example.com
  5. Goto Your App โ†’ Scopes and click on + Add scopes
    1. Select User
    2. Check user:read and user_profile
  6. Fill in required fields under Information like Short Description, Developer Contact Information, etc.
  7. Copy Client ID and Client Secret
  8. Update web/.env.local REACT_APP_OAUTH_ZOOM_ID with Client ID
  9. Update api/.env.local OAUTH_ZOOM_ID with Client ID
  10. Update api/.env.local OAUTH_ZOOM_SECRET with Client Secret

โ†‘ all integrations


GitHub

  1. Read official flow: https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps
  2. Create a new OAuth application: https://github.com/settings/applications/new and fill in following:
    1. Application name enter your application name, eg: Example
    2. Homepage URL enter your website url, eg: https://example.com
    3. Authorization callback URL:
      1. For development, enter http://localhost:3000/authorize/
      2. For production, enter https://example.com/authorize/
  3. Copy Client ID and Client Secret
  4. Update web/.env.local REACT_APP_OAUTH_GITHUB_ID with Client ID
  5. Update api/.env.local OAUTH_GITHUB_ID with Client ID
  6. Update api/.env.local OAUTH_GITHUB_SECRET with Client Secret

โ†‘ all integrations


GitLab

  1. Read official flow: https://docs.gitlab.com/ee/api/oauth2.html#web-application-flow
  2. Create a new OAuth application: https://gitlab.com/profile/applications and fill in following:
    1. Name enter your application name, eg: Example
    2. Homepage URL enter your website url, eg: https://example.com
    3. Authorization callback URL enter http://localhost:3000/authorize/ and on new line https://example.com/authorize/
  3. For Scopes check read_user, profile and email
  4. Click on Save application button and copy Application ID and Secret
  5. Update web/.env.local REACT_APP_OAUTH_GITLAB_ID with Application ID
  6. Update api/.env.local OAUTH_GITLAB_ID with Application ID
  7. Update api/.env.local OAUTH_GITLAB_SECRET with Secret

โ†‘ all integrations


DigitalOcean

  1. Read official flow: https://docs.gitlab.com/ee/api/oauth2.html#web-application-flow
  2. Create a new OAuth application: https://cloud.digitalocean.com/account/api/applications/new and fill in following:
    1. Name enter your application name, eg: Example
    2. Homepage URL enter your website url, eg: https://example.com
    3. Description enter info about your app, eg: OAuth example application
    4. Authorization callback URL:
      1. For development, enter http://localhost:3000/authorize/
      2. For production, enter https://example.com/authorize/
  3. Click on Save button
  4. Click on More โ†’ View and copy Client ID and Client Secret
  5. Update web/.env.local REACT_APP_OAUTH_DIGITALOCEAN_ID with Client ID
  6. Update api/.env.local OAUTH_DIGITALOCEAN_ID with Client ID
  7. Update api/.env.local OAUTH_DIGITALOCEAN_SECRET with Client Secret

โ†‘ all integrations


Bitbucket

  1. Read official flow: https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html
  2. Create a new OAuth application: https://bitbucket.org/USERNAME/workspace/settings/oauth-consumers/new and fill in following:
    1. Name enter your application name, eg: Example
    2. Homepage URL enter your website url, eg: https://example.com
    3. Description enter info about your app, eg: OAuth example application
    4. Callback URL:
      1. For development, enter http://localhost:3000/authorize/
      2. For production, enter https://example.com/authorize/
  3. Under Permissions โ†’ Account check Email and Read
  4. Click on Save button
  5. Click on Name of your application and copy Key and Secret
  6. Update web/.env.local REACT_APP_OAUTH_BITBUCKET_ID with Key
  7. Update api/.env.local OAUTH_BITBUCKET_ID with Key
  8. Update api/.env.local OAUTH_BITBUCKET_SECRET with Secret

โ†‘ all integrations


Azure

  1. Read official flow: https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
  2. Create a new OAuth application: https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade and fill in following:
    1. Name enter your application name, eg: Example
    2. Supported account types choose Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
    3. Redirect URI:
      1. For development, enter http://localhost:3000/authorize/
      2. For production, enter https://example.com/authorize/
  3. Goto Dashboard โ†’ App โ†’ Certificates & secrets and under Client secrets click on + New client secret
    1. Enter Description, eg: Example Secret Key
    2. For Expires choose Never
  4. Click on Add button and copy the Secret value
  5. Click on Name of your application and copy Application (client) ID and Secret
  6. Update web/.env.local REACT_APP_OAUTH_AZURE_ID with Application (client) ID
  7. Update api/.env.local OAUTH_AZURE_ID with Application (client) ID
  8. Update api/.env.local OAUTH_AZURE_SECRET with Secret
  9. Optionally, change OAUTH_AZURE_TENANT as per your requirement.

โ†‘ all integrations


Spotify

  1. Read official flow: https://developer.spotify.com/documentation/general/guides/authorization-guide
  2. Create a new OAuth application: https://developer.spotify.com/dashboard/applications and fill in following:
    1. App or Hardware Name enter your application name, eg: Example
    2. App or Hardware Description enter your application name, eg: Example OAuth app
  3. Goto Dashboard โ†’ App and click on Edit settings
  4. For Redirect URIs make following entries:
    1. For development, enter http://localhost:3000/authorize/
    2. For production, enter https://example.com/authorize/
  5. Copy Client ID and Client Secret
  6. Update web/.env.local REACT_APP_OAUTH_SPOTIFY_ID with Client ID
  7. Update api/.env.local OAUTH_SPOTIFY_ID with Client ID
  8. Update api/.env.local OAUTH_SPOTIFY_SECRET with Client Secret

โ†‘ all integrations


Shopify

  1. Read official flow: https://shopify.dev/tutorials/authenticate-with-oauth
  2. Create a new OAuth application: https://partners.shopify.com/PARTNER_ID/apps/new/applications and fill in following:
    1. App name enter your application name, eg: Example
    2. App URL enter your application URL, eg: https://example.com
    3. For Whitelisted redirection URL(s) make following entries:
      1. For development, enter http://localhost:3000/authorize/
      2. For production, enter https://example.com/authorize/
  3. Create a store https://partners.shopify.com/PARTNER_ID/stores for testing
  4. Copy API key and API secret key
  5. Update web/.env.local REACT_APP_OAUTH_SHOPIFY_ID with API key
  6. Update web/.env.local REACT_APP_OAUTH_SHOPIFY_STORE with your test store ID
  7. Update api/.env.local OAUTH_SHOPIFY_ID with API key
  8. Update api/.env.local OAUTH_SHOPIFY_SECRET with API secret key
  9. Update api/.env.local OAUTH_SHOPIFY_STORE with your test store ID

โ†‘ all integrations

Core Structure

oauth
  โ”œโ”€โ”€ api
  โ”‚   > PORT 4000
  โ”‚   > localhost:4000
  โ”‚   > api.example.com
  โ”‚
  โ”œโ”€โ”€ web
  โ”‚   > PORT 3000
  โ”‚   > localhost:3000
  โ”‚   > example.com
  โ”‚
  โ””โ”€โ”€ README.md (you are here)

โ†‘ back to top

Setup and Running

  • Prerequisites

    • Node (v12.x)
    • MongoDB (v4.x)
    • IDE (Webstorm / Visual Studio Code)
  • Clone repository git clone [email protected]:atulmy/oauth.git oauth

  • API

    • Switch to api directory cd oauth/api
    • Configuration
      • Create local environment file cp .env.dev .env.local
      • Edit .env.local for SECURITY_SECRET, DATABASE_URL and OAUTH_.. values
    • Setup
      • Install packages npm install
    • Run
  • Web

    • Switch to web directory cd oauth/web
    • Configuration
      • Create local environment file cp .env.dev .env.local
      • Edit .env.local for REACT_APP_OAUTH_.. values
    • Setup
      • Install packages npm install
    • Run

โ†‘ back to top

Contribution

Found an integration not working? Open an issue / Send a Pull Request with fixes.

Looking for a particular OAuth integration not yet added? Open an issue / Send a Pull Request with additional integrations.

Authors

  • Atul Yadav - GitHub ยท Twitter
  • [YOUR NAME HERE] - Feel free to contribute to the codebase by resolving any open issues, refactoring, adding new features, writing test cases or any other way to make the project better and helpful to the community. Feel free to fork and send pull requests.

Community reviews

Hire me

Looking for a developer to build your next idea or need a developer to work remotely? Get in touch: [email protected]

Donate

If you liked this project, consider donating to support it โค๏ธ

Donate via PayPal

License

Copyright (c) 2020 Atul Yadav http://github.com/atulmy

The MIT License (http://www.opensource.org/licenses/mit-license.php)

More Repositories

1

crate

๐Ÿ‘• ๐Ÿ‘– ๐Ÿ“ฆ A sample web and mobile application built with Node, Express, React, React Native, Redux and GraphQL. Very basic replica of stitchfix.com / krate.in (allows users to get monthly subscription of trendy clothes and accessories).
JavaScript
2,400
star
2

fullstack-graphql

๐ŸŒˆ Simple Fullstack GraphQL Application. API built with Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux to access the API. Written in ES6 using Babel + Webpack.
JavaScript
1,026
star
3

fullstack-javascript-architecture

โœ๏ธ Opinionated project architecture for Full-Stack JavaScript Applications.
JavaScript
652
star
4

gql-query-builder

๐Ÿ”ง Simple GraphQL Query Builder
TypeScript
354
star
5

node-express-react-redux-zwitter

๐Ÿฃ A basic clone of Twitter (Boilerplate App) - Separate API (express+mongo) and Frontend (react+redux) folders using Node, Express, MongoDB, React (create-react-app), React Router v4 and Redux.
JavaScript
92
star
6

universal-react

๐ŸŒ A simple universal react application with server side rendering built with latest versions of React (v16+), React Router (v5+), Redux (v4+), Express (v5+), Webpack (v4+), Babel Preset ES6 ๐Ÿ‘จโ€๐Ÿ’ป
JavaScript
79
star
7

hire-smart

โœ… HIRE SMART (community edition) - Streamline hiring process, scheduling interviews and tracking candidates.
JavaScript
70
star
8

react-recoil

A sample implementation of React Recoil.
JavaScript
44
star
9

react-native-curated

๐Ÿ’โ€โ™‚๏ธ Hand picked collection of packages, tutorials and more for React Native.
43
star
10

wispy

๐ŸŒฑ An experimental lightweight (remote procedure call) API pattern.
JavaScript
36
star
11

meteor-react-simple-chat

๐Ÿ’ฌ Basic chat application using Meteor 1.4 and React.
JavaScript
25
star
12

meteor-baseui

๐Ÿ“ฑ๐Ÿ–ฅ Basic UI: Mobile + Web
HTML
13
star
13

node-react-zwitter

๐Ÿง NodeJS, Express, MySQL and React Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
13
star
14

cv

๐Ÿ“„ Curriculum Vitae
12
star
15

meteor-bootstrap

๐Ÿฃ Meteor Bootstrap / Boilerplate Project with essential folder structures and packages.
JavaScript
10
star
16

meteor-mafia

๐ŸŽฎ Mafia: The Party Game!
JavaScript
9
star
17

meteor-rock-paper-scissors

๐Ÿ‘Šโœ‹โœŒ๏ธ Rock Paper Scissors - Play online with your friends or with computer
JavaScript
7
star
18

meteor-tictactoe

๐ŸŽฎ Tic Tac Toe - Play multiplayer online with your friends
JavaScript
6
star
19

node-express-handlebars-zwitter

๐Ÿง NodeJS, Express, Mongoose and Handlebars Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
5
star
20

jquery-connectors

๐Ÿ”— Draws a path between two HTML elements.
JavaScript
5
star
21

fullstack-validator

๐Ÿ›ก A simple validation library for server and client side JavaScript applications.
TypeScript
5
star
22

meteor-1.4-zwitter

๐Ÿง Meteor 1.4 Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
4
star
23

tool-aspectratio

๐Ÿ“ฑ ๐Ÿ–ฅ ๐Ÿ’ป Calculate aspect ratio online for images, display screens, montors and mobile easily.
PHP
4
star
24

php-angular-easyapp

An easy, flexible, very light weight, extendable, small to medium scale application template. Recommended for beginners exploring web technologies. Best suited for SPAs and RIAs.
PHP
4
star
25

node-basics

Basics of NodeJS
JavaScript
4
star
26

meteor-react-zwitter

๐Ÿง Meteor + ReactJS Boilerplate App - Zwitter (Basic clone of Twitter)
JavaScript
3
star
27

baseui

๐Ÿ“ฑ๐Ÿ–ฅ Basic UI: Mobile + Web
HTML
3
star
28

node-express-angular-job-finder

๐Ÿ” A sample app built on Mongo, Express and Angular and Node
CSS
2
star
29

workstation

1
star