# User authorization callbacks

You can provide a function to be called after user succesful user authorization in widget.

```
closer.init({
  orgId: "00000000-0000-0000-0000-000000000000",
  onUserAuthorizationSuccess: (authorizationResult: UserAuthorizationResult) => console.log("USER AUTHORIZED")
});
```

Authorization result object:

```
interface UserAuthorizationResult {
  roomId: string;
  idToken?: string;
}
```

&#x20;If you use OAuth for customers authorization that provides ID Token, it will be available in callback.

```
closer.init({
  orgId: "00000000-0000-0000-0000-000000000000",
  onUserAuthorizationSuccess: (authorizationResult: {idToken?: string}) => console.log(idToken)
});
```

Sometimes your user might not authorize, especially when using OAuth. There is other callback for that situation.

```
closer.init({
  orgId: "00000000-0000-0000-0000-000000000000",
  onUserAuthorizationFailed: () => console.log("User authorization failed")
});
```


---

# 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://support.closer.app/guide/getting-deeper/user-authorization-callbacks.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.
