Skip to content

Commit 6358314

Browse files
committed
initial commit
0 parents  commit 6358314

12 files changed

+1386
-0
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
OAUTH_ISSUER_URL=REDACTED_REPLACE_WITH_ISSUER_URL
2+
OAUTH_CLIENT_ID=REDACTED_REPLACE_WITH_CLIENT_ID
3+
OAUTH_CLIENT_SECRET=REDACTED_REPLACE_WITH_CLIENT_SECRET

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## About
2+
3+
Quickly add OAuth2/OpenId Connect to an [Express.js](https://expressjs.com/) app. In this sample, we will showcase how to easily fetch OAuth2 based [accessToken](https://cloudentity.com/developers/basics/tokens/access-token/), [refreshToken](https://cloudentity.com/developers/basics/tokens/refresh-token/), openid connect [idtoken](https://cloudentity.com/developers/basics/tokens/id-token/), token claims and user info within the express app.
4+
5+
## Run the application
6+
7+
**Minimum requirements:**
8+
9+
- NodeJS 20.x+
10+
- NPM 10.x+
11+
12+
**Cloudentity SaaS Tenant**
13+
14+
- Register for a [free Cloudentity SaaS tenant](https://authz.cloudentity.io/register)
15+
16+
**Clone the repo**
17+
18+
Clone this github repo
19+
20+
**Install dependencies:**
21+
22+
```bash
23+
# Make sure you are in the correct app directory
24+
cd ce-samples-oauth2-openid-connect-nodejs-express
25+
26+
npm install
27+
```
28+
29+
**Set environment values**
30+
31+
Open the `.env` file and configure these values after registering an OAuth Client application within the Cloudentity SaaS tenant
32+
33+
* Create a new workspace
34+
* [Attach an identity pool with users](https://cloudentity.com/developers/howtos/identity/store-users/) or an external identity provider
35+
* Create an OAuth client application
36+
37+
![Alt text](create-oauth-client-application.jpeg "OAuth Client application")
38+
39+
* Set redirect URL to `http://localhost:3002`
40+
41+
![Alt text](oauth-client-app-redirect-uri.png "OAuth client app redirect uri")
42+
43+
* Subscribe to scopes to include `email`, `openid`, `profile` , `offline`
44+
45+
![Alt text](oauth-client-app-scopes.png "Client Apps scopes")
46+
47+
* Make sure PKCE is not enabled for all client applications
48+
49+
![Alt text](oauth-pkce-for-all-apps.png "PKCE flag for all client apps")
50+
51+
52+
* Copy the below values from above created client application to `.env` file
53+
* `CLIENT ID`
54+
* `CLIENT SECRET`
55+
* `ISSUER URL`
56+
57+
58+
**To start the dev server:**
59+
60+
```bash
61+
node server.js
62+
```
63+
64+
**Verify application**
65+
66+
* Launch `http://localhost:3002`
67+
68+
* User will be redirected to Cloudentity login page
69+
70+
![Alt text](cloudentity-login-page.png "Cloudentity login page")
71+
* Authenticate the user
72+
73+
* You will see following tokens, claims and userInfo in the page
74+
75+
![Alt text](app-expected-response.png "App expected response")
76+
77+
## More Information
78+
79+
Developers can use [Cloudentity platform](https://cloudentity.com/) for free to explore one of the most complete OAuth authorization server with advanced OAuth profile and a Financial-API Grade provider. [See pricing for different tiers](https://cloudentity.com/pricing/)
80+
81+
Use [Cloudentity developer portal](https://cloudentity.com/developers/) to explore more dev tutorials, integration articles and OAuth patterns
82+
83+
## Contact
84+
85+
For any issues with this repo, please mail issues to [[email protected]](mailto:[email protected])

app-expected-response.png

653 KB
Loading

cloudentity-login-page.png

95.4 KB
Loading
324 KB
Loading

oauth-client-app-redirect-uri.png

500 KB
Loading

oauth-client-app-scopes.png

407 KB
Loading

oauth-pkce-for-all-apps.png

375 KB
Loading

0 commit comments

Comments
 (0)