Invalid client in aqueduct's db_and_auth/wildfire example - oauth-2.0

I am new to Aqueduct and I am facing a invalid client error whenever I try to make a request to the /auth/token or /auth/code route.
I have already added the OAuth2.0 client and verified the secret is correct.
My request to /auth/token looks like this:
Future main() async {
var http2 = new http.Client();
var clientID = "com.wildfire.mobile";
var clientSecret = "myspecialsecret ";
var body = "username=usr&password=pwd&grant_type=password";
var clientCredentials = new Base64Encoder().convert(
"$clientID:$clientSecret".codeUnits);
var response = await
http.post(
"http://localhost:8081/auth/token",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic $clientCredentials"
},
body: body);
And when I try logging in in /auth/code with a username in the _user database the server throws a 400:invalid_client

It was indeed a misconfiguration issue. After deleting all my databases, I added a database.yaml file, which I thought was the same as the config.yaml but apparently is not.
The database.yaml looks like this:
username: adan
password: pass
host: localhost
port: 5432
databaseName: wildfire_db
while the config.yaml looks like this:
database:
username: adan
password: pass
host: localhost
port: 5432
databaseName: wildfire_db
I also ran the aqueduct auth and aqueduct db commands without the --connect flag, i.e. using the config files.

Related

Defining a property via process.env in javascript

I'm new to JavaScript and stuck.
I'm writing my first "real" Electron App and want to connect via sftp. (ssh2-sftp-client to be more specific)
When I set up the connection like the example:
sftp.connect({
host: '192.168.76.173',
port: '22',
username: 'Backup',
password: 'PasswordInPlainText'
}).then(() => {
return sftp.list('/Backups/Server');
}).then(data => {
console.log(data, 'the data info');
}).catch(err => {
console.log(err, 'catch error');
});
everything works like a charm. But when I try to "hide" my credentials in an .env file:
sftp.connect({
host: process.env.HOST,
port: process.env.PORT,
username: process.env.USERNAME,
password: process.env.PASSWORD
}).then(() => {
return sftp.list('/Backups/Server');
}).then(data => {
console.log(data, 'the data info');
}).catch(err => {
console.log(err, 'catch error');
});
I get the error message:
Error: connect: getConnection: All configured authentication methods failed
I checked via
console.log("Host to connect: "+ process.env.HOST)
and the correct output is:
Host to connect: 192.168.76.173
The content of the .env File is
HOST='192.168.76.173'
PORT='22'
USERNAME='Backup'
PASSWORD='PasswordInPlainText'
So this my first time working with environment Variables at all, so I'm guessing I misunderstood something, or a JavaScript property can't be defined by a string this way.
Your problem is that the .env files are not supported in NodeJS by default and you might have some env variables already with the same names and different values (defined in the system probably).
You could either use a NPM package like dotenv or parse the contents of the file by yourself.
You could also test it like that:
// Place this code before you use the ENV variables.
// Replace the `<variables>` with the real data
// and test if your code works with the ENV variables.
process.env.HOST = '<your host ip>';
process.env.PORT = '<your port>';
process.env.USERNAME = '<username>';
process.env.PASSWORD = '<password>';

"Client does not support authentication protocol requested by server; consider upgrading MySQL client" even after downgrading to mysql#5.7

I was originally on mysql 8.0 which gave me the error
ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client
when trying to run my server. I saw on multiple sources that downgrading to mysql#5.7 would solve the problem because 5.7 uses native password authentication, but the same error is still present after downgrading to the earlier version. Are there any other known reasons as to why the error still persists?
Here is my config file:
config.js
// import dependencies
const util = require("util");
const mysql = require("mysql");
// import environment variables
const env = {
env: process.env.NODE_ENV,
host: process.env.DB_HOST,
database: process.env.DB_NAME,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD
}
const database = mysql.createConnection({
host: env.host,
database: env.database,
user: env.user,
password: env.password
});
database.connect(err => {
if (err) {
console.log("Connection " + err);
} else {
console.log(`Connection Success: You are now connected to the ${env.env} database`);
}
});
// promisify all database queries
database.query = util.promisify(database.query);
// export database
module.exports = database;
MySQL 8.0 introduced a default SHA256 encryption that many clients do not understand. You have many options, the easiest being using the older MySQL native password (see https://mysqlserverteam.com/upgrading-to-mysql-8-0-default-authentication-plugin-considerations/) authentication. Change the account to use the older authentication and your client connector will be happy.

How to establish connection to the neo4j graph database in javascript with js2neo driver

I get this error when i try to use the connection
WebSocket connection to 'ws://bolt//localhost:7687' failed: Error in connection establishment: net::ERR_NAME_NOT_RESOLVED
Downloaded neo4j desktop
started the browser and added a local graph database.
Downloaded the js2neo driver
<script src="js/js2neo.min.js"></script>
connected to the database as per http://js2neo.org/
var cx = js2neo.open({ host: "bolt://localhost", user: "neo4j",
password: "1234567890!" })
test the content of the database
cx.run("MATCH (n) RETURN *", { onRecord: console.log })
Your host configuration is not good (it's host not url).
So instead of
var cx = js2neo.open({ host: "bolt://localhost", user: "neo4j",
password: "1234567890!" })
do this :
var cx = js2neo.open({ host: "localhost", user: "neo4j",
password: "1234567890!" })

Exception when connecting to Database through Dart

I was trying to connect to MySQL database in Flutter application using sqljocky5 using the below code using dart language
void getInfo () async {
var pool = new ConnectionPool(
host: 'localhost',
port: 3305,
user: 'root',
password: 'mysql',
db: 'smartlender',
max :5
);
print('test');
var results = await pool.query('SELECT employee.firstName FROM smartlender.employee;'); // exception is thrown here
results.forEach((row){ // for each loop to add data to the list created above
names.add(row[0].toString());
});
Then I received this exception:
I have working connection to MySQL database and the query is exiting without an error .
I appreciate a lot if someone could resolve this issue .
Isn't it default Mysql port number 3306?

SFTP equivalent of HTTP URL

What can be the URL of SFTP equivalent of the following HTTP URL:
https://myftp.example.com/FolderName/FileName.csv
Also, my SFTP URL will be authenticated with following User Credentials:
Username: User1
Password: Pass1
I tried the following URL:
sftp://User1:Pass1#myftp.example.com:22/FolderName/FileName.csv

Resources