Skip to content

Commit

Permalink
Merge pull request #231 from sbeh/login
Browse files Browse the repository at this point in the history
Support more characters in login credentials
  • Loading branch information
DutchmanNL authored Oct 29, 2023
2 parents eaa4075 + 23f6972 commit aca3498
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ class Discovergy extends utils.Adapter {
// Get all meters connected to Discovergy account
async doDiscovergyCall(endpoint, urlencoded_parameters) {

const requestUrl = `https://${settings.Username}:${settings.Password}@api.discovergy.com/public/v1/${endpoint}?${urlencoded_parameters}`;
const requestUrl = `https://api.discovergy.com/public/v1/${endpoint}?${urlencoded_parameters}`;

try {
await request(requestUrl, async (error, response, body) => {
await request({
url: requestUrl,
headers: {
"Authorization" : 'Basic ' + new Buffer(`${settings.Username}:${settings.Password}`).toString('base64')
}
}, async (error, response, body) => {

if (!error && response.statusCode === 200) {

Expand Down Expand Up @@ -152,8 +157,13 @@ class Discovergy extends utils.Adapter {
async doDiscovergyMeter(endpoint, urlencoded_parameters, meterId) {
try {
const stateName = this.allMeters[meterId].serialNumber;
const requestUrl = `https://${settings.Username}:${settings.Password}@api.discovergy.com/public/v1/${endpoint}?meterId=${meterId}`;
await request(requestUrl, async (error, response, body) => {
const requestUrl = `https://api.discovergy.com/public/v1/${endpoint}?meterId=${meterId}`;
await request({
url: requestUrl,
headers: {
"Authorization" : 'Basic ' + new Buffer(`${settings.Username}:${settings.Password}`).toString('base64')
}
}, async (error, response, body) => {

if (!error && response.statusCode === 200) {

Expand Down

0 comments on commit aca3498

Please sign in to comment.