Authentication
Authentication module will be used by Connection. This module allow we authenticate with kintone app by password authenticator or API token authenticator. This module is also support basic authenticator.
Warning
- If both the Token and Password Authentication are specified, the Token Authentication will be ignored and the Password authentication will be used.
Constructor
Parameter
(none)
Sample code
Init authentication module
Source codeAuth kintoneAuth = new Auth();
Methods
setPasswordAuth(username, password)
Set password authentication for Authentication module.
Parameter
Name | Type | Required | Description |
---|---|---|---|
username | String | yes | The username that is able to authenticate on kintone app |
password | String | yes | The password that is able to authenticate on kintone app |
Return
Sample code
Set password authentication
Source codeString username = "cybozu"; String password = "cybozu"; kintoneAuth.setPasswordAuth(username, password);
setApiToken(apiTokenString)
Set Api Token for Authentication module.
Parameter
Name | Type | Required | Description |
---|---|---|---|
apiToken | String | yes | The apiToken that is able to authenticate on kintone app |
Return
Set APIToken authentication
Source codeString apiToken = "123456789abcdefghijklmnopqrstuvwxyz"; kintoneAuth.setApiToken(apiToken);
setBasicAuth(username, password)
Set Basic authentication for Authentication module.
Parameter
Name | Type | Required | Description |
---|---|---|---|
username | String | yes | The username that is able to authenticate on kintone app |
password | String | yes | The password that is able to authenticate on kintone app |
Return
Sample code
Set basic authentication
Source codeString username = "cybozu"; String password = "cybozu"; kintoneAuth.setBasicAuth(username, password);
createHeaderCredentials()
Provide the list of HTTP Headers which use to authentication in.
Parameter
(none)
Return
Array<HTTPHeader>
Sample code
Provide the list of HTTP Headers which use to authentication in
Source codefor (HTTPHeader header : kintoneAuth.createHeaderCredentials()) { connection.setRequestProperty(header.getKey(), header.getValue()); }
setClientCert(cert, password)
Set certificate by certificate data
Parameter
Name | Type | Required | Description |
---|---|---|---|
cert | InputStream | yes | Data read from certificate file received from kintone |
password | String | yes | The password from kintone to decode the cert file |
Return
Sample code
Set certificate by certificate data
Source codeAuth certAuth = new Auth(); certAuth.setPasswordAuth("YOUR_KINTONE_ID", "YOUR_KINTONE_PASSWORD"); String certPassword = "YOUR_CERT_PASSWORD" String certPath = "YOUR_CERT_PATH" InputStream cert = new FileInputStream(certPath); auth.setClientCert(cert, certPassword) Connection connection = new Connection("YOUR_DOMAIN", certAuth, -1);
setClientCertByPath(filePath, password)
Set certificate by path
Parameter
Name | Type | Required | Description |
---|---|---|---|
filePath | String | yes | Path to kintone certificate file |
password | String | yes | The password from kintone to decode the cert file |
Return
Sample code
Set certificate by path
Source codeAuth certauth = new Auth(); certAuth.setPasswordAuth("YOUR_KINTONE_ID", "YOUR_KINTONE_PASSWORD"); String certPassword = "YOUR_CERT_PASSWORD" String certPath = "YOUR_CERT_PATH" certauth.setClientCertByPath(certPath, certPassword); Connection connection = new Connection("YOUR_DOMAIN", certAuth);