#Okta AngularJS Examples The following examples will provide you with custom AngularJS wrappers around the Okta AuthSDK.
##Sample Scenarios
Currently, these samples use the module OktaAuthClient
defined in the file okta-angular.js
. The OktaAuthClient
is an AngularJS wrapper for the AuthSDK implementation. To use the provided authClient
and widgetClient
wrappers, inject them into your module.
###OpenID Connect with Custom Login Interface
Demonstrates the OpenID Connect Implicit Flow - receiving an id_token
and token
:
- Sign in with Password: Authenticates user with name/password and exchanges a sessionToken for an
id_token
andaccessToken
(JWT) - Renew Token: Uses the current session with Okta to obtain a new
id_token
(JWT) - Decode Token: Decodes the current
id_token
revealing the encoded contents - Request Protected Resource (API): Uses the
token
as an OAuth2 Bearer Access Token to request a protected resources from an API (you must first authenticate) - Signout: Signs the user out of existing session
###Single-Page Web App (SPA) using Okta Sign-In Widget
Demonstrates the OpenID Connect Implicit Flow - receiving an id_token
:
- Sign in using the Okta Sign-In Widget following the OpenID Connect authentication flow
- Renew Token: Exchanges the current
id_token
for a newid_token
- Signout: Signs the user out of existing session
###Pre-requisites This sample application was tested with an Okta org. If you do not have an Okta org, you can easily sign up for a free Developer Okta org.
- Verify OpenID Connect is enabled for your Okta organization.
Admin -> Applications -> Add Application -> Create New App -> OpenID Connect
- If you do not see this option, email [email protected] to enable it.
- In the Create A New Application Integration screen, click the Platform dropdown and select Single Page App (SPA)
- Press Create. When the page appears, enter an Application Name. Press Next.
- Add http://localhost:8080 to the list of Redirect URIs
- Click Finish to redirect back to the General Settings of your application.
- Copy the Client ID, as it will be needed for the Okta AuthSDK client configuration.
- Enable CORS access to your Okta organization
- Finally, select the People tab and Assign to People in your organization.
To test out the custom claims/scopes ability with the returned accessToken
, additionally configure the following:
- In the Authorization Server screen, click the OAuth 2.0 Access Token Edit button
- Add the custom scope
gravatar
. - Add the custom claim name
user_email
and valueappuser.email
- Add the gravatar scope to your
custom-login/app.js
file:
// custom-login/app.js
app.run(function(authClient){
...
clientScopes = [
'openid',
'email',
'profile',
'groups',
'gravatar'
];
});
Once the project is cloned, install node.js on your machine. Using npm install http-server.
npm install http-server -g
Usage: http-server [path] [options]
Start the web server with http-server
http-server [path] [options]
[path]
is the root directory (e.g. http-server angular-sso-samples/
)
Navigate to http://localhost:8080/
to sign in.
The server receives the OAuth2 Bearer Access Token to request a protected resources from an API after JWT token validation. To run the server, first download the dependencies by running:
npm install
Once installed, run node server.js
to start the server on default port :9000
.