Ionic+ Office 365 (Deprecated)

Setup your application's code

Add the following lines to your base code

// www/js/services.js

angular.module('', [])

.factory('Auth', function($rootScope) {

  var Auth0Cordova = require('@auth0/cordova');
  var auth0 = require('auth0-js');
  var userProfile = {};

  var auth0Config = {
    clientId: 'YOUR_CLIENT_ID',
    domain: 'YOUR_AUTH0_DOMAIN',
    callbackURL: location.href,
    packageIdentifier: 'YOUR_PACKAGE_ID'

  auth0Config.clientID = auth0Config.clientId;

  var webAuth = new auth0.WebAuth(auth0Config);

  function setSession(authResult) {
    var expiresAt = JSON.stringify((authResult.expiresIn * 1000) + new Date().getTime());
    window.localStorage.setItem('access_token', authResult.accessToken);
    window.localStorage.setItem('id_token', authResult.idToken);
    window.localStorage.setItem('expires_at', expiresAt);

  function isAuthenticated() {
    var expiresAt = JSON.parse(window.localStorage.getItem('expires_at'));
    return < expiresAt;
  function getProfile(cb) {
    var accessToken = localStorage.getItem('access_token');
    if (!accessToken) {
      throw new Error('Access token must exist to fetch profile');

    webAuth.client.userInfo(accessToken, (err, profile) => {
      if (profile) {
        userProfile = profile;
      cb(err, profile);

  function login() {
    var client = new Auth0Cordova(auth0Config);

    var options = {
      scope: 'openid profile offline_access'

    client.authorize(options, function(err, authResult) {
      if (err) {
        throw new Error(err);
      if (authResult && authResult.accessToken && authResult.idToken) {

  function logout() {

  return {
    login: login,
    logout: logout,
    getProfile: getProfile,
    isAuthenticated: isAuthenticated

Create an Application in Auth0 dashboard 

Create an Application in Auth0 dashboard

Create an Enterprise Office 365 (Deprecated) Connection under Connections / Enterprise section

Create a Enterprise Connection for authentication
Authentication Security and Availability

Authentication Built for Security & High Availability

Auth0 is the easiest way for developers to integrate enterprise-grade authentication and identity management to any app.

Industry Standard Compliance
Authentication Certifications and Compliance

SOC 2, HIPAA/BAA, EU/US Privacy Shield Framework, Open ID Certified.

Learn More
Built by Security Experts
uthentication Experts

Continuously reviewed and tested by external security experts. Strong password encryption and hashing algorithms, at rest and in transit.

Learn More
What Our Customers Say
Authentication Case Studies

Continuously reviewed and tested by external security experts. Strong password encryption and hashing algorithms, at rest and in transit.

Learn More
Availability & trust
Authentication Availability

Uptime time in 3 different regions.

Learn More
Host Anywhere
Auth0 Appliance

Deploy On-Premises or on Cloud on your data center or Auth0’s one.

Learn More
Auth0 Active Users

Get Auth0 free for 7,000 active users per month with unlimited logins

  • Single Sign On
  • Passwordless Login
  • Up to 2 Social Identity Providers
  • Multifactor Authentication
  • User Management
  • Extensibility (Run custom code on Auth)

Some of the companies that trust us every day

Atlassian - Authentication CustomerPBS - Authentication CustomerNVIDIA - Authentication CustomerMozilla - Authentication CustomerBluetooth - Authentication CustomerFinancial Times - Authentication CustomerJet - Authentication CustomerHMH - Authentication CustomerOptimizely - Authentication CustomerPolaris - Authentication CustomerHarper - Authentication CustomerNews Corp - Authentication Customer