# Application

## Members

### `id : string`

The Client ID of this application.

### `secret : string?`

The Client Secret of this application.

### `scope : string`

The [OpenID scope](/identity/scopes-and-claims.md) of this application.

### `responseTypes : string[]`

The OpenID response types of this application.

### `redirectUrls : string[]`

The OpenID redirect URLs of this application.

### `postLogoutRedirectUrls : string[]?`

The OpenID post logout redirect URLs of this application.

## Methods

### `constructor(config)`

Create a Vulos Application object based on a configuration object that has the following properties:

* `id: string` (required): The Client ID of the Application (you can obtain this from the Vulos Identity dashboard by creating an application);
* `secret: string`: The Client Secret of the Application (you can obtain this from the Vulos Identity dashboard by creating an application, non-applicable for browser applications that use the implicit flow);
* `scope: string` (required): The OIDC scopes - "permissions" that your application has, they must match your application in the Vulos Identity dashboard.
* `redirectUrls: string[]` (required): The URLs where Vulos Identity redirects after a user interaction;
* `postLogoutRedirectUrls: string[]`: The URLs where Vulos Identity redirects after a successful logout;
* `responseTypes: string[]`: The OIDC response types (defaults to `['code']` if a client secret is provided);

```javascript
const application = new Application({
    // this is an example Client ID, replace with your own
    id: "796FZE9KLOLO0VSSBNOE",
    // this is an example Client Secret, replace with your own
    secret: "5a9b30a4f2f7f5edb5087e2258c3ecc0fc4129853e28f2f48f10b21b60388f1f",
    // this is an example scope string, modify according to your needs
    scope: "openid offline_access organization:manage",
    
    // change these URLs to match your site or application
    redirectUrls: [ "http://localhost/callback/login" ],
    postLogoutRedirectUrls: [ "http://localhost/callback/logout" ],
    
    // https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html
    responseTypes: [ "code" ]
})
```

### `createAuth(authApi, endpoint?)`

Create an authentication object for this application based on a constructor specified in `authApi` that's provided by [`@vulos/identity-browser-sdk`](/reference/identity-javascript-sdk/the-frontend-auth-package.md) or [`@vulos/identity-node-sdk`](/reference/identity-javascript-sdk/the-backend-auth-package.md).

{% hint style="info" %}
If an `endpoint` argument is provided, that will be used instead of the default Vulos Identity endpoint.
{% endhint %}

```javascript
// If you intend to use this code in the frontend, 
// use "FrontendAuth" from "@vulos/identity-browser-sdk"
import { BackendAuth } from "@vulos/identity-node-sdk"

// ...

const auth = application.createAuth(BackendAuth)
```

{% hint style="info" %}
See [`BaseAuth`](/reference/identity-javascript-sdk/the-base-package/authentication/baseauth.md) for more information.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.vulos.io/reference/identity-javascript-sdk/the-base-package/authentication/application.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
