Class: ApiConfig

josm/api~ ApiConfig


new ApiConfig()

ApiConfig provides methods and properties for configuring API parameters

ApiConfig provides methods and properties for configuring API parameters.
Source:

Members


<static> authMethod : string

Get or set the authentication method.

Get or set the authentication method. JOSM uses two authentication methods:
basic
Basic authentication with a username and a password
oauth
Authentication with the OAuth protocol.
Type:
  • string
Properties:
Name Type Description
authMethod string the authentication method
Source:
Example
import { ApiConfig } from 'josm/api'
ApiConfig.authMethod   // -> the current authentication method

// set OAuth as authentication method
ApiConfig.authMethod = 'oauth'

<static, readonly> defaultServerUrl

Get the default server URL

Get the default server URL.
Properties:
Name Type Description
defaultServerUrl string the default server URL
Source:
Example
import { ApiConfig } from 'josm/api'
ApiConfig.defaultServerUrl   // -> the default server url

<static> serverUrl

Get or set the API server URL.

Get or set the API server URL.
get
Replies the currently configured server URL or undefinend, if no server URL is configured.
set
Sets the current server URL. If null or undefined, removes the current configuration. Accepts either a string or a URL. Only accepts http or https URLs.
Properties:
Name Type Description
serverUrl string
Source:
Example
import { ApiConfig } from 'josm/api'
ApiConfig.serverUrl   // -> the current server url

// set a new API url
ApiConfig.serverUrl = 'http://api06.dev.openstreetmap.org'

Methods


<static> getCredentials(authMethod [, options])

Gets the credentials, i.e. username and password for the basic authentication method.
Parameters:
Name Type Argument Description
authMethod string the authentication method. Either basic or oauth
options module:josm/api~SetOrGetCredentialOptions <optional>
additional options
Source:
Returns:
the credentials
Type
BasicCredentials | OAuthCredentials
Example
import { ApiConfig } from 'josm/api'

// get username/password for the current OSM API server
const credentials = ApiConfig.getCredentials('basic')

<static> setCredentials(authMethod, credentials [, options])

Set the credentials, i.e. username and password for the basic authentication method. Basic authentication credentials are either an instance of PasswordAuthentication or an object {user: string, password: string}. OAuth authentication credentials are either an instance of OAuthToken or an object {key: string, secret: string}.
Parameters:
Name Type Argument Description
authMethod string the authentication method. Either 'basic' or 'oauth'.
credentials module:josm/api~BasicAuthParameters | module:josm/api~OAuthParameters | OAuthToken | PasswordAuthentication the credentials
options module:josm/api~SetOrGetCredentialOptions <optional>
additional options
Source:
Returns:
the credentials
Type
object
Example
import { ApiConfig } from 'josm/api'

// set the credentials
ApiConfig.setCredentials('basic', { user:'test', password:'my-password' })