ApiConfig provides methods and properties for configuring API parameters.
Name | Description |
---|---|
Properties | |
authMethod | Get or set the authentication method. |
defaultServerUrl | Get the default server URL- |
serverUrl | Get or set the API server URL. |
Methods | |
getCredentials | Gets the credentials. |
setCredentials | Set the credentials. |
authMethod:string
Get or set the authentication method.
JOSM uses two authentication methods:
basic
oauth
var conf = require("josm/api").ApiConfig;
conf.authMethod; // -> the current authentication method
// set OAuth as authentication method
conf.authMethod = "oauth";
defaultServerUrl:string
Get the default server URL.
var conf = require("josm/api").ApiConfig;
conf.defaultServerUrl; // -> the default server url
serverUrl:string
Get or set the API server URL.
get
set
var conf = require("josm/api").ApiConfig;
conf.serverUrl; // -> the current server url
// set a new API url
conf.serverUrl = "http://api06.dev.openstreetmap.org";
getCredentials:object
Gets the credentials, i.e. username and password for the basic authentication method.
Named optionshost:string
Name | Type | Description |
---|---|---|
authMethod | string | the authentication method. Either "basic" or "oauth". |
options | object | (optional) additional options (see above) |
var conf = require("josm/api").ApiConfig;
// get username/password for the current OSM API server
var credentials = conf.getCredentials("basic");
setCredentials:object
Set the credentials, i.e. username and password for the basic authentication method.
Basic authentication credentials are either an instance of java.net.PasswordAuthentication or
an object {user: string, password: string}
.
OAuth authentication credentials are either an instance of OAuthToken or
an object {key: string, secret: string}
.
host:string
Name | Type | Description |
---|---|---|
authMethod | string | the authentication method. Either "basic" or "oauth". |
credentials | object | the credentials. |
options | object | (optional) additional options (see above) |
var conf = require("josm/api").ApiConfig;
// set the credentials
conf.setCredentials("basic", {user:"test", password:"apassword"});