---
title: Methods
slug: wYDu-methods
docTags: 
createdAt: 2020-04-06T11:26:13.000Z
---

- $pinc.oauth.authorized()
- $pinc.oauth.authorizedList()
- $pinc.oauth.processCommand()
- $pinc.oauth.bind()
- $pinc.oauth.client.connections()
- $pinc.oauth.client.display()
- $pinc.oauth.revoke()

## authorized(provider, \[userId], callback)

Allows you to query whether the user has previously authorized an Integration. User this interface when you wish to query the authorization status for a single provider.

arguments

| Argument | Description                                                                                        |
| -------- | -------------------------------------------------------------------------------------------------- |
| provider | Internal provider name. See [Provider reference](docId\:Z26CDo6omB40W2fyMu_UT)                     |
| user\_Id | optional: Defaults to the [data-user-id](docId\:SIx7fJ9iQb5Z2gV_AA96R) attribute in the script tag |
| callback | JavaScript callback.                                                                               |

**Example**

```javascript


function checkAuthorized(){
		var provider = "googlemail";
		var userId = "user@myapp.com"
		$pinc.oauth.authorized(provider, userId, (authorized)=>{
			console.log(authorized);
		})
	}
    
```

## authorizedList(userId, callback)

Gives you a list of providers that the user has authorized

**Example**

```javascript

function checkAuthorized(){
		var userId = "user@myapp.com"
		//set the userId to null if you want it to default 
		$pinc.oauth.authorizedList(userId, (providerList)=>{
			//array providerList
			console.log (providerList)
		})
	}

```

## processCommand(json\_params)

Inititates the OAuth authorization process for the given provider. Ensure that this method is called synchronously on user interaction (onclick etc.). An asynchronous call to this function will block any authorizations that work with popups.

| Param    | Description                                                                                        |
| -------- | -------------------------------------------------------------------------------------------------- |
| provider | Internal provider name. See [Provider reference](docId\:Z26CDo6omB40W2fyMu_UT)                     |
| user\_id | optional: Defaults to the [data-user-id](docId\:SIx7fJ9iQb5Z2gV_AA96R) attribute in the script tag |

**Example**

```javascript


function clickHandler(){
    /*optional
        user_id: if you want to override the data-user-id specified in the script tag
    */
    var commandParams = {
        "provider":"googlecalendar",
        "user_id":"..."
        };
    $pinc.oauth.processCommand(commandParams)
}

```

## bind(div)

Pass the div element for scenarios where the div is dynamically added to the page using JavaScript of shadow DOM. &#x20;


```javascript


function lateRender(elDiv){
    /*
    ensure that the DOM element being passed has the folowing attributes
        <div 
            data-oauth-ui="list-columns/list/list-panel" 
            data-oauth-ui-switches="statusOn,disconnect" 
            data-oauth-icon-size="Medium/Large" 
            data-oauth-button-color="#007BFF" 
            data-oauth-ui-providers="googlecalendar,msgraphcalendar,..." 
            data-oauth-ui-providerTypes=""></div>
     */
    $pinc.oauth.bind(elDiv);
}
```

## revoke(provider,userId)

Invokes the token revocation for the current user. If the provider does no offer API based revocation then the tokens are deleted from the Pathfix databases/caches. &#x20;

**Example**

```javascript


function revoke(){
    $pinc.events.on("$pinc.oauth","revoked",data=>{console.log(data)})
    $pinc.oauth.revoke("googlecalendar");
}
```

[Provider reference](docId\:Z26CDo6omB40W2fyMu_UT)
