# How to store login settings when creating a new app (that integrates with an api)

**URL:** <https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555>\
**Category:** Developers\
**Created:** [February 16, 2022, 10:08pm UTC](https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555 "2022-02-16T22:08:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![reyntjensw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/reyntjensw/32/34189_2.png) [@reyntjensw](https://community.homey.app/u/reyntjensw)\
**Post date:** [February 16, 2022, 10:08pm UTC](https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555/1 "2022-02-16T22:08:21Z")

</div>

Hi

It’s my first time creating an app and I have a question.  
When using the login window, I’d like to store the login credentials in the (homey)settings.

But I don’t know how, I’ve tried already to add these fields (username and password) in the driver.compose file.

```auto
"settings": [
        {
            "id": "username",
            "type": "text",
            "label": {
                "en": "WEN username"
            }
        },
        {
            "id": "password",
            "type": "password",
            "label": {
                "en": "WEM password"
            }
        }
    ]

```

The SDK has a settings section but I’m not getting there.

> **[ManagerSettings - Homey Apps SDK v3](https://apps-sdk-v3.developer.homey.app/ManagerSettings.html)**

This was my try on storing the credentials but that did not work out

```auto
               this.homey.settings.setSettings(username, data.username);
                this.homey.settings.setSettings(password, data.password);

```

The error that I’m getting is **TypeError: this.homey.settings.setSettings is not a function**

Any suggestions here?

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [February 17, 2022, 4:15am UTC](https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555/2 "2022-02-17T04:15:10Z")

</div>

> [@reyntjensw](#):
>
> ```auto
> this.homey.settings.setSettings(username, data.username);
>                
> 
> ```

Use  
`this.homey.settings.set('username', data.username);`

notice also the username is a string so add the quotes.  
The other thing to be aware of is that the device data (if obtained using this.getData()) is read only, so you won’t be able to charge that after pairing. Therefore I recommend you store username and password in the settings when the device is add and not the data.

---

<div class="post-metadata">

**Author:** ![reyntjensw](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/reyntjensw/32/34189_2.png) [@reyntjensw](https://community.homey.app/u/reyntjensw)\
**Post date:** [February 17, 2022, 7:37am UTC](https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555/3 "2022-02-17T07:37:30Z")

</div>

Hi Adrian

Thanks for the suggestion, everything is up and running!

---

<div class="post-metadata">

**Author:** ![IamNague](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/iamnague/32/39117_2.png) [@IamNague](https://community.homey.app/u/IamNague)\
**Post date:** [February 28, 2022, 6:00pm UTC](https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555/4 "2022-02-28T18:00:21Z")

</div>

I’m trying to do the exact same thing for global app settings, but I can’t figure out my mistake.  
I built a very basic index.html, settings are stored and well dispayed.  
But using this:

```auto
'use strict';
const Homey = require('homey');
class MyApp extends Homey.App {

	onInit() {
		const timer = this.homey.settings.get('timer');
	}

```

give me this error:

```auto
─────────────── Logging stdout & stderr ───────────────
/app.js:11
                const timer = this.homey.settings.get('timer');
                                         ^
TypeError: Cannot read property 'settings' of undefined
    at MyApp.onInit (/app.js:11:28)
    at /opt/homey-client/node_modules/homey-apps-sdk-v2/lib/SDK.js:216:31
    at FSReqCallback.oncomplete (fs.js:167:5)

```

Any help will be welcome.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [February 28, 2022, 6:03pm UTC](https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555/5 "2022-02-28T18:03:59Z")

</div>

> [@IamNague](#):
>
> `homey-apps-sdk-v2`

Use SDKv3, not SDKv2.

---

<div class="post-metadata">

**Author:** ![IamNague](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/iamnague/32/39117_2.png) [@IamNague](https://community.homey.app/u/IamNague)\
**Post date:** [February 28, 2022, 6:29pm UTC](https://community.homey.app/t/how-to-store-login-settings-when-creating-a-new-app-that-integrates-with-an-api/60555/6 "2022-02-28T18:29:58Z")

</div>

Off course, thanks a lot.
