Connection details for Priority Web API sand box (demo environment) - priority-web-sdk

According to the Web API introduction page, I have to connect to the development environment by calling the login(...) function passing it the following configuration object:
{
username: '<username>',
password: '<password>',
url: '<url>',
tabulaini: '<tabula.ini>',
language: <language>,
company: '<companyName>',
appname: 'Customers'
}
Does the Prioritysoftware provides connection settings details (username, password, url, etc.) for Priority Web API demo environment as it provides for Priority REST API demo environment (using the following postman collection)?

Yes it does. Try
var configuration = {
username: 'apidemo',
password: '123',
url: 'https://www.eshbelsaas.com/ui',
tabulaini: 'tabmob.ini',
language: 3,
company: 'usdemo'
};

Related

IOT device getting a double post from Axios

I have an IOT device, its coded in Lua, I didn't do that part of the project, so I don't know much about it.
I have 2 almost identical axios posts.
run via an app
await axios.post(url,{ cmd:'{"cmd": {"uuid":"'+serial+'","name":"RR","value":"'+key+'"}}' } , { auth: { username: 'admin', password: 'rLVeGRk9ezWj' } }
run via a local HTML page to test:
const body = { cmd:'{"cmd": {"uuid":"'+serial+'","name":"RR","value":"'+key+'"}}' }
const resp2 = await axios.post(url, body, { auth: { username: 'admin', password: 'rLVeGRk9ezWj' })
In the lua side, the HTML example works perfectly. My app version (#1 above), actually sends twice. Causes a "Ignoring new incoming data. Failed to get header".
I compared headers, content-length and looks identical.
To anyone else experiencing this, the Lua device was splitting the data when it was too long. The IOT developer had to make a change to handle long posts

Nodemailer OAUTH Gmail connection (Error: connect ETIMEDOUT 74.125.140.108:465)

Im trying to use OAUTH 2.0 to send emails with Gmail API using Nodemailer
I have Enable the Gmail API and i have clientId, clientSecret, refreshToken and accessToken (refreshtoken and accesstoken were taken from developers.google.com/oauthplayground) because these all were needed for OAUTH to work.
i have followed every detail form (https://nodemailer.com/smtp/oauth2/#examples)
But i'm getting following error
{ Error: connect ETIMEDOUT 74.125.140.108:465
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
errno: 'ETIMEDOUT',
code: 'ESOCKET',
syscall: 'connect',
address: '74.125.140.108',
port: 465,
command: 'CONN' }
But there is a catch when i use Plain username and password there is no connection timeout error because i have already enabled less secure app access form (https://myaccount.google.com/lesssecureapps) so there is no error in sending emails using plain username and password but this is not a good approach so OAUTH is the solution
here is my code for you to check (its an express app) running in development running on http://localhost:3000
var nodemailer = require('nodemailer');
var transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
service: 'gmail',
auth: {
type: 'OAuth2',
user: 'mygmailaddress#gmail.com',
clientId: 'clientID',
clientSecret: 'clientSecret',
refreshToken: 'refresh token obtained from https://developers.google.com/oauthplayground',
accessToken: 'access token also obtained from https://developers.google.com/oauthplayground'
}
});
var mailOptions = {
from: 'me <myemailaddress#gmail.com>',
to: '',
subject: 'Subject ',
text: 'Some thing',
};
transporter.sendMail(mailOptions, (error, response) => {
if(error){
console.log(error); // Always giving Error: connect ETIMEDOUT 74.125.140.108:465
} else {
console.log(response);
}
});
it not even try to login because when login fails it gives error of wrong credentials (checked with plain username and password)
*Note please don't mark this question as duplicate because i have check almost all other question and answers but nothing worked
some people said its because of firewall setting i have check that too but didn't worked
So whats the issue and how to solve it
Your port no is wrong for gmail. Use This Format for gmail
const nodeMailer = require('nodemailer');
let transporter = nodeMailer.createTransport({
host: "smtp.gmail.com",
port: 587,
secure: false, // true for 587, false for other ports
requireTLS: true,
auth: {
user: your email,
pass: your password,
},
});
let mailOptions = {
from: 'from#gmail.com',
to: 'to#gmail.com',
subject: 'Sending Email using Node.js',
text: 'That was easy!'
};
transporter.sendMail(mailOptions, function(error, info){
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
After looking to your problem i assume that when generated the OAuth credentials e.g(clienId and Clientsecret ) you did not added https://mail.google.com/ in you scope on connect screen because you would need verification form google to add these scope for the credentials
you must have added this to your scope on (https://developers.google.com/oauthplayground) but i'm sure you have add this to your scope on consent screen as well before generating credentials
OAuth consent screen
as you are in Development mode and running your application on localhost so you don't have private domain and privacy policy
Adding https://mail.google.com to your scope before generating clientId and Cliensecret will resolve your problem

How to make a request to a website, which has user authentication, to access its contents?

I am working on an IOS app as my college project. Basically my college has a website which has login form[no sign up forms there], and students using their unique college ID and their own password can login into this website and access things like courses they have registered for, their grades etc. Now in my app i have a log in form and i want the students to be able to login with the same existing ID and password and access the same information as they would be able to do on the website itself. Simply speaking, i want to access the post authentication information on the website in my app. How do i approach this problem?
It depends if your school server allows request from different origins (different domain). If, yes just check when you login what info it posts and to which address. Then send a request to this address with the same info and check the result from the request.
Example:
Just use chrome or firefox dev inspector, fill the login form, send it and check the request done.
Let say the request done is a POST # http://myschool.com/login with username and password form, and the result if successful is a 200 code and a cookie. Then in node js you could do:
const querystring = require('querystring');
const request = require('request');
const form = {
username: 'usr',
password: 'pwd',
};
const formData = querystring.stringify(form);
const contentLength = formData.length;
request(
{
headers: {
'Content-Length': contentLength,
'Content-Type': 'application/x-www-form-urlencoded'
},
uri: 'http://myschool.com/login',
body: formData,
method: 'POST'
},
function (err, res, body) {
// check the result here
}
);

jwt authentication in iOS client nodejs server via third party authenticator

I am trying to wrap my head around using json webtoken (jwt) based authentication on a server coupled to using a third party (say google) to authenticate the user. Originally I've managed to build my own login and jwt handling scheme with jsonwebtoken on my nodejs server, but we need a client running on an iOS system to interact with it and started looking around for a solution where we don't have to code so much client code (requesting new token when expired etc.) and thought that we would use a third party library to do this for us.
The thing is I did not find anything that would do this for us. I found libraries that could handle connecting the client to a google api for the client, I found user identification handled by google, but didn't find anything that would handle actually getting a jwt that the server would except as a genuine user.
My question is essentially this: we have an iOS client and a nodejs server and would like to use google to authenticate our users and have the client call api-s on our nodejs server, with as much of the authentication process handled by some third party library (google's?), how should we get around to this?
As a note, I've seen passport but that seems to operate with sessions only, and I would have to solve the jwt handling by myself were I to use that.
The iOS part is not ready, but I managed to use google to authenticate and authorize without a session in the browser. The idea is, that the client logs in to google (see here for web app) and google graciously also gives you a token with the login, which will be good for the server. On the nodejs side I used passport and the google-id-token strategy (see on github). There are quite a few strategies for google out there, but this one works. Although, this has a shortcoming, it can't accept the token in the header, but I fixed that in a pull request (see here).
Since I had a bit of a problem of how to use the User.findOrCreate part of all the passport examples, I'll put in my code here that covers a full working example:
var passport = require('passport');
var GoogleTokenStrategy = require(passport-google-id-token)
passport.use(new GoogleTokenStrategy({
clientID: config.googleAuth.clientID,
clientSecret: config.googleAuth.clientSecret,
},
function(parsedToken, googleId, done) {
console.log(parsedToken);
console.log(googleId);
User.findOne({ 'google.id': googleId }, function (err, user) {
if (!user) {
var testuser = new User({
name: parsedToken.payload.name,
givenName : parsedToken.payload.givenName,
familyName : parsedToken.payload.familyName,
nameunderscore : parsedToken.payload.name.split(' ').join("_"),
admin: false,
email: parsedToken.payload.email,
settings: {save_folder:"default"},
'google.id' : googleId,
'google.email' : parsedToken.payload.email,
});
testuser.save(function(err) {})
}
return done(err, user);
});
}
));
User comes from mongodb in a separate js:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
module.exports = mongoose.model('User', new Schema({
name: String,
nameunderscore : String,
givenName: String,
familyName: String,
admin: Boolean,
settings: {
save_folder: String
},
email: String,
google: {
id: String,
email: String
}
}));
And this is how I added the passport strategy to a router (note that session is set to false):
var apiRoutes = express.Router();
apiRoutes.use(passport.authenticate('google-id-token',{ session: false }));
Now every call to any route in apiRoutes must send on id_token with a valid google token to get access.

How do I set API keys for Twitter in Meteor without using the GUI

How do I get rid of the configure button on the frontend from the {{>loginbuttons}} tag?
So far I have tried:
if (Meteor.isServer) {
Meteor.startup(function(){
Accounts.loginServiceConfiguration.remove({
service: 'twitter'
});
Accounts.loginServiceConfiguration.insert({
service: 'twitter',
consumerKey: 'KEY',
secret: 'SECRET'
});
});
}
I can't find documentation for accounts-twitter, I can't seem to understand where Meteor packages code can be looked at.
From the docs http://docs.meteor.com/#/full/meteor_loginwithexternalservice
First, add the service configuration package:
meteor add service-configuration
Then, in your app:
// first, remove configuration entry in case service is already configured
ServiceConfiguration.configurations.remove({
service: "weibo"
});
ServiceConfiguration.configurations.insert({
service: "weibo",
clientId: "1292962797",
loginStyle: "popup",
secret: "75a730b58f5691de5522789070c319bc"
});
try
// first, remove configuration entry in case service is already configured
ServiceConfiguration.configurations.remove({
service: "twitter"
});
ServiceConfiguration.configurations.insert({
service: "twitter",
consumerKey: "1292962797",
loginStyle: "popup",
secret: "keyyyyy"
});
This Github repo, shows the use for Facebook, Twitter, Google and Github.
They behave the same, although args may be different.

Resources