This example app shows how to build a hangman game with Angular, MongoDB, Node, and Express.
Prerequisites: Node.js, MongoDB, and an Okta developer account.
Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's REST API and makes it easy for developers to authenticate, manage, and secure users + roles in any application.
To install this example application, run the following commands:
git clone https://github.com/oktadeveloper/okta-angular-mongodb-hangman-example.git
cd okta-angular-mongodb-hangman-example
This will get a copy of the project installed locally. To install all of its dependencies and start each app, follow the instructions below.
To run the server, cd into the hangman-server
folder and run:
npm install && node src/index.js
To run the client, cd into the hangman-client
folder and run:
npm install && npm start
If you don't have an Okta developer account, please create one. Then, create a new OIDC app on Okta:
- Log in to your developer account, navigate to Applications > Add Application.
- Select Single-Page App > Next.
- Give the application a name, change all instances of
https://localhost:8080
tohttps://localhost:4200
, and click Done.
Set your domain and copy the clientId
into hangman-server/src/auth.ts
.
NOTE: The value of {yourOktaDomain}
should be something like dev-123456.okta.com
. Make sure you don't include -admin
in the value!
const oktaJwtVerifier = new OktaJwtVerifier({
clientId: '{yourClientId}',
issuer: 'https://{yourOktaDomain}/oauth2/default'
});
For the client, set the issuer
and copy the clientId
into hangman-client/src/app/app.module.ts
.
OktaAuthModule.initAuth({
issuer: 'https://{yourOktaDomain}/oauth2/default',
redirectUri: 'http://localhost:4200/implicit/callback',
clientId: '{yourClientId}'
})
This example uses the following open source libraries from Okta:
Please post any questions as comments on the blog post or post them to Stack Overflow with the okta
tag.
Apache 2.0, see LICENSE.