I'm using cloudrail-node-js v.2.17.3.
I want to simply get an unique Identifier for Twitter Authentication.
However, this always returns an error :
{ [Error: The URL the RedirectReceiver returns does not contain all necessary keys in the query, it's missing at least oauth_token,oauth_verifier]
message: 'The URL the RedirectReceiver returns does not contain all necessary keys in the query, it\'s missing at least oauth_token,oauth_verifier' }
Here is my code :
const cloudrail = require('cloudrail-si');
cloudrail.Settings.setKey(cloudrailKey);
let Service = new cloudrail.services.Twitter(cloudrail.RedirectReceivers.getLocalAuthenticator(3000), twitterKey, twitterSecret, `http://localhost:3000`, "state");
Service.getIdentifier(function (err, id) {
console.log(err, id);
});
Thanks in advance.
Related
I'm attempting to refactor the "Node.JS PowerBI App Owns Data for Customers w/ Service Principal" code example (found HERE).
My objective is to import the data for the "config.json" from a table in my database and insert the "workspaceId" and "reportId" values from my database into the "getEmbedInfo()" function (inside the "embedConfigServices.js" file). Reason being, I want to use different configurations based on user attributes. I am using Auth0 to login users on the frontend, and I am sending the user metadata to the backend so that I can filter the database query by the user's company name.
I am able to console.log the config data, but I am having difficulty figuring out how to insert those results into the "getEmbedInfo()" function.
It feels like I'm making a simple syntax error somewhere, but I am stuck. Here's a sample of my code:
//----Code Snippet from "embedConfigServices.js" file ----//
async function getEmbedInfo() {
try {
const url = ;
const set_config = async function () {
let response = await axios.get(url);
const config = response.data;
console.log(config);
};
set_config();
const embedParams = await getEmbedParamsForSingleReport(
config.workspaceId,
config.reportId
);
return {
accessToken: embedParams.embedToken.token,
embedUrl: embedParams.reportsDetail,
expiry: embedParams.embedToken.expiration,
status: 200,
};
} catch (err) {
return {
status: err.status,
error: err.statusText,
}
};
}
}
This is the error I am receiving on the frontend:
"Cannot read property 'get' of undefined"
Any help would be much appreciated. Thanks in advance.
Carlos
The error is because of fetching wrong URL. The problem is with the config for the Service Principal. We will need to provide reportId, workspaceId for the SPA and also make sure you added the service principal to workspace and followed all the steps from the below documentation for the service principal authentication.
References:
https://learn.microsoft.com/power-bi/developer/embedded/embed-service-principal
I am using the Xero Api with Nodejs and the xero-node library.
I have completed the oAuth flow and saved the token to the database. The issue i am now having is continually getting a 403 forbidden error when attempting to get anything from Xero be that Contacts, Accounts or Users. Sample code is below
I can get tenants ok without an issue however anything else doesn't work. I have checked the scopes to make sure when I am setting up the client they are correct which they are.
var getStuff = async(tokenSet) => {
await xero.setTokenSet(tokenSet);
const tenants = await xero.updateTenants();
const xeroTenantId = tenants[0].id // {String} Xero identifier for Tenant
const ifModifiedSince = new Date("2020-02-06T12:17:43.202-08:00");
const where = 'IsSubscriber==true'; // {String} Filter by an any element
const order = 'LastName ASC'; // {String} Order by an any element
console.log(tenants);
try {
const response = await xero.accountingApi.getUsers(xeroTenantId, ifModifiedSince, where, order);
console.log(response.body || response.response.statusCode)
}
catch (err) {
/// console.log(err);
console.log(`There was an ERROR! \n Status Code: ${err.response.statusCode}.`);
console.log(`ERROR: \n ${JSON.stringify(err.response.body, null, 2)}`);
}
}
Which scopes have been added to the access token you are passing through? You can decode your token here https://jwt.io/
Also - you need to pass the ‘tenant.tenantId’ to the function. I believe the tenant.id actually relates to the connection id which is coming back from the /connections endpoint.
My hunch is that is the issue. Also curious how that’s working, as updateTenants() should have the empty function call on the end. Is that working for you?
I am trying to upload files to stripe which are submitted by the user in my frontend to verify their identity before they can sell on my platform.
Currently, the files are sent via an API request to the backend where I can upload a single file, and afterwards, I attach it to that user's account.
let file = {
data: fs.readFileSync(files.IDFront.path),
name: files.IDFront.name,
type: files.IDFront.type
}
stripe.files.create({
purpose: 'identity_document',
file
}, function(err, file) {
if(err) res.send({sucess:false, error: err})
else {
//attach to user's account
}
This works just fine, but some identity documents require pictures of the front and back, so my question is can I upload two files at once using stripe.files.create? I can't seem to find anything in Stripe's API docs which mentions this, and I don't want to use stripe.files.create twice in one function because I feel that isn't a very efficient way to write the function.
Any suggestions would be greatly appreciated
It is important to note that your documents still need to be sent to Stripe in their own calls in order to get their respective tokens.
The function below takes an object of document names and the returned stripe tokens
{
document: <stripeToken1>,
additional_document: <stripeToken2>
}
You can then iterate through these and append to the update object in one go
// create the document object template
const documentObject = {
individual: {
verification: {},
},
}
Object.entries(imageTokens).map(([_, token]) => {
const [keyToken] = Object.entries(token)
// separate key and token from object
const [documentKey, stripeTokenId] = keyToken
// convert our naming convention to stripes expected naming
const checkedKey = documentKey === 'document_front' ? 'document' :
documentKey
// append to document object
documentObject.individual.verification[checkedKey] = {
front: stripeTokenId,
}
return await stripe.accounts.update(stripeAccountId, documentObject)
I am trying to get users that are present in array onlineUsers, but it is giving me following error. Can someone please give me work around if this doesn't work
CODE:
exports.post = function(request, response) {
var onlineUsers = ["6990"];
// Tables
var userTable = request.service.tables.getTable('Users');
userTable.where(
function(ou) {
return ou.search(this.id) != -1;
},onlineUsers).read({
success : function(users){
response.send(statusCodes.OK, { message : users });
}
});
};
ERROR:
Error in script '/api/test_find.js'. Error: The expression 'ou.search(this.id)'' is not supported.
Try the following:
userTable.where(function(ou) {
return this.id in ou;
}, onlineUsers)
Keep in mind that the SQL generated contains a separate where clause for each element of onlineUsers, so it can become quite inefficient if the array contains many elements. We're looking at improving the query API.
Please explain with one example as I am getting Error: 400 - The specified resource description is invalid.
Basically, I want to update badge value. But there is no template for badge registration in WnsService API document (http://azure.github.io/azure-sdk-for-node/azure-sb/latest/WnsService.html). So, I am trying with "createRawTemplateRegistration" template to update the badge value.
Please help me on this.
You can directly use the function sendBadge() to push badge value to client devices.
Please try the following code:
var azure = require('azure');
var notificationHubService = azure.createNotificationHubService('<hubname>', '<connectionstring>');
notificationHubService.wns.sendBadge(null,99,function(error,response){
if(error) console.log(error);
console.log(response);
})
Any further concern, please feel free to let me know.
update
Do you mean that you want only one template and to handle all the types of notifications including Raw, Toast, Badge? If so, I think the answer is negative. According the description http://azure.github.io/azure-sdk-for-node/azure-sb/latest/WnsService.html#createRawTemplateRegistration:
Remember that you have to specify the X-WNS-Type header
So the header option is required. And according the REST API which is invoked via this api in nodejs is Create Registration, and we can find the description:
The BodyTemplate element is mandatory, as is the X-WNS-Type header.
So we should specify the notification type for the template.
update1
This code sample works fine on my side:
var channel = '<devicetoken>';
var templateMessage = { text1: '$(message)' };
notificationHubService.wns.createRawTemplateRegistration(channel,'tag',JSON.stringify(templateMessage), {headers: { 'X-WNS-Type': 'wns/raw' }},
function (e, r) {
if (e) {
console.log(e);
} else {
console.log({
id: r.RegistrationId,
deviceToken: r.DeviceToken,
expires: r.ExpirationTime
});
}
}
)