# Namespace: OauthUtil

## OauthUtil

Source:
  - lib/oauth_util.js, line 12

### Methods

#### (static) exports.getAuthorizeURL(config, callback)

Attempts to get an OAuth verification URL using the given API configuration.

##### Parameters:

Name | Type | Description
--- | --- | ---
`config` | Object | The information needed to access the Jira API ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`host` | string |  |  | The hostname of the Jira API.
`protocol` | string | <optional> | https | The protocol used to accses the Jira API.
`port` | number | <optional> | 443 | The port number used to connect to Jira.
`path_prefix` | string | <optional> | "/" | The prefix to use in front of the path, if Jira isn't at "/"
`version` | string | <optional> | 2 | The version of the Jira API to which you will be connecting. Currently, only version 2 is supported.
`oauth` | Object |  |  | The oauth information ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`consumer_key` | string |  | The consumer key of the application accessing Jira.
`private_key` | string |  | The private key of the application accessing Jira.
`callback_url` | string | <optional> | The callback URL to be called after the token is generated. If this is not included, the user will be given a verification code after authorizing the token, instead of Jira making a callback to the application.
`callback` | OauthUtil~getOauthUrlCallback | The function called when the URL has been retrieved.

Source:
  - lib/oauth_util.js, line 35

#### (static) exports.swapRequestTokenWithAccessToken(config, callback)

Given an OAuth token, the token secret, and an access verification code (provided by Jira), swap an OAuth request token with an OAuth access token.

##### Parameters:

Name | Type | Description
--- | --- | ---
`config` | Object | The information needed to access the Jira API ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`host` | string |  |  | The hostname of the Jira API.
`protocol` | string | <optional> | https | The protocol used to accses the Jira API.
`port` | number | <optional> | 443 | The port number used to connect to Jira.
`version` | string | <optional> | 2 | The version of the Jira API to which you will be connecting. Currently, only version 2 is supported.
`oauth` | Object |  |  | The oauth information ###### Properties
Name | Type | Description
--- | --- | ---
`consumer_key` | string | The consumer key of the application accessing Jira.
`private_key` | string | The private key of the application accessing Jira.
`token` | string | The OAuth Token supplied by Jira.
`token_secret` | string | The OAuth Token secret supplied by Jira.
`oauth_verifier` | string | The verified code given to the user after authorizing the OAuth token.
`callback` | OauthUtil~swapRequestTokenCallback | The function called when the token has been swapped.

Source:
  - lib/oauth_util.js, line 76

#### (static) generateOAuthObject(config) → {exports.OAuth}

Utility function to generate an OAuth object.

##### Parameters:

Name | Type | Description
--- | --- | ---
`config` | Object | The information needed to access the Jira API ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`host` | string |  |  | The hostname of the Jira API.
`protocol` | string | <optional> | https | The protocol used to accses the Jira API.
`port` | number | <optional> | 443 | The port number used to connect to Jira.
`path_prefix` | string | <optional> | "/" | The prefix to use in front of the path, if Jira isn't at "/"
`version` | string | <optional> | 2 | The version of the Jira API to which you will be connecting. Currently, only version 2 is supported.
`oauth` | Object |  |  | The oauth information ###### Properties
Name | Type | Attributes | Description
--- | --- | --- | ---
`consumer_key` | string |  | The consumer key of the application accessing Jira.
`private_key` | string |  | The private key of the application accessing Jira.
`callback_url` | string | <optional> | The callback URL to be called after the token is generated. If this is not included, the user will be given a verification code after authorizing the token, instead of Jira making a callback to the application.

Source:
  - lib/oauth_util.js, line 110

##### Returns:

The generated object.

Type
  exports.OAuth

### Type Definitions

#### getOauthUrlCallback(error, oauth)

Callback used by getOauthUrl.

##### Parameters:

Name | Type | Description
--- | --- | ---
`error` | * | The error which occurred, if any.
`oauth` | Object | The OAuth information retrieved from the Jira API. ###### Properties
Name | Type | Description
--- | --- | ---
`url` | String | The URL that should be visited by the user to verify the OAuth access.
`token` | String | The OAuth Token retrieved from the Jira API.
`token_secret` | String | The OAuth Token Secret retrieved from the Jira API.

Source:
  - lib/oauth_util.js, line 148

#### swapRequestTokenCallback(error, access_token)

Callback used by swapRequestTokenWithAccessToken

##### Parameters:

Name | Type | Description
--- | --- | ---
`error` | * | The error which occurred, if any.
`access_token` | string | The access token retrieved from Jira.

Source:
  - lib/oauth_util.js, line 158