# Ionic 3 MS ADAL data validation

**URL:** <https://forum.ionicframework.com/t/ionic-3-ms-adal-data-validation/175621>\
**Category:** ionic-v3\
**Created:** [October 16, 2019, 5:21am UTC](https://forum.ionicframework.com/t/ionic-3-ms-adal-data-validation/175621 "2019-10-16T05:21:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nirmalya-S](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/nirmalya-s/32/123358_2.png) [@Nirmalya-S](https://forum.ionicframework.com/u/Nirmalya-S)\
**Post date:** [October 16, 2019, 5:21am UTC](https://forum.ionicframework.com/t/ionic-3-ms-adal-data-validation/175621/1 "2019-10-16T05:21:00Z")

</div>

I’m using Ionic 3 MS ADAL and its returning data. But the thing is, when we apply Adal service in a web application, it stores data by default. But for a ionic 3 app, how could I store data or validating the stored data?? Every time its asking for the user name and password.

---

<div class="post-metadata">

**Author:** ![Nirmalya-S](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/nirmalya-s/32/123358_2.png) [@Nirmalya-S](https://forum.ionicframework.com/u/Nirmalya-S)\
**Post date:** [October 17, 2019, 5:36am UTC](https://forum.ionicframework.com/t/ionic-3-ms-adal-data-validation/175621/2 "2019-10-17T05:36:05Z")

</div>

Below is my working Code for MS ADAL with Ionic 3.

```auto
const SsoConfig = {
      "authority": "https://login.windows.net/common",
      "resourceUrl": "https://graph.windows.net",
      "clientId": [clientId]
      "redirectUrl": "https://login.microsoftonline.com/common/oauth2/nativeclient"
    };

let authContext: AuthenticationContext = this.msAdal.createAuthenticationContext(SsoConfig.authority);
authContext.acquireTokenAsync(SsoConfig.resourceUrl, SsoConfig.clientId, SsoConfig.redirectUrl, "", "")
      .then((authResponse: AuthenticationResult) => {
        console.log(authResponse);
      })
      .catch((e: any) => {
        console.log('Authentication failed')
      });

```

Now, with the above code I have to login every time. Its not storing the data. So, I tried with the below code, but its not working.

```auto
authContext.tokenCache.readItems().then(function (catchItems: any) {
      if (catchItems.length > 0) {
        authority = catchItems[0].authority;
        console.log(catchItems);
      }

      authContext.acquireTokenSilentAsync(SsoConfig.resourceUrl, SsoConfig.clientId, "")
        .then((silentAuthResponse: AuthenticationResult) => {
          console.log(silentAuthResponse);
        })
        .catch((e: any) => {          
          authContext.acquireTokenAsync(SsoConfig.resourceUrl, SsoConfig.clientId, SsoConfig.redirectUrl, "", "")
            .then((authResponse: AuthenticationResult) => {              
              console.log(authResponse);
            })
            .catch((e: any) => {
              this.Message = "Authentication failed";
              console.log(e)
            });
        });;
    });

```

Could someone help me on this??
