I use azure-graph in my Node.js project:
const MsRest = require('ms-rest-azure');
const credentials = await MsRest.loginWithServicePrincipalSecret(keys.appId, keys.pass, keys.tenantId, { tokenAudience: 'graph' });
const GraphkManagementClient = require('azure-graph');
const client = new GraphkManagementClient(credentials, subscriptionId);
return client.users.get(principalID);
I want to use the Azure SDK also to send emails.
I know how to do that in low level using the API directly:
But I want to do it via the SDK like the rest of my project.
My problem is, I have not found any method for sending an email in the docs: azure-graph package. I need a method that allows me (with the proper privileges of course) to send email as any user in the organization.
You can use the Graph JavaScript SDK which is a wrapper around the Microsoft Graph API that can be used server-side and in the browser to send mails to users. Please refer to Graph Javascript SDK to learn more about the same. Also, refer to nodejs-connect-sample to use Microsoft Graph API and the Graph JavaScript SDK to send an email.
Related
How can I create an Azure App Registration programmatically using Typescript/Javascript? I have seen some questions asked a few years ago and some mention using the Azure SDK and provide links that are now dead.
I need to create Azure App Registrations and manually setting them up takes a while, I'd like to be able to create them programmatically to automate this process.
One of the workaround you can follow to achieve the above requirement,
From the official Microsoft Documentation we can use the below to create an Application using javascript.
const options = {
authProvider,
};
const client = Client.init(options);
const application = {
displayName: 'Display name'
};
await client.api('/applications')
.post(application);
For details about how to add the SDK to your project and
create an authProvider instance, see the SDK
documentation.
Alternatively, As suggested by #Alex Wayne , We can use the Graph API to create an application using below:
POST https://graph.microsoft.com/v1.0/applications
Content-type: application/json
{
"displayName": "Display name"
}
For more information please refer the below links:-
SO THREAD| Register an Application in Azure AD using the graph API.
as a request from azure to have globally-unique Storage name, I'm trying to figure out a way to check if the Storage Account name is available or not using javascript SDK,
but I didnt find anything in the Azure js SDK.
I did found REST API:
https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/check-name-availability
but i'm not sure how to use it using javascript. and i dont want to use header and subsicropionid maunnly, I would like to use token and then try to use the api.
but if JS SDK have this function it will be great.
I did found for the container but this is not what i wanted.
You can use #azure/arm-storage package. Please refer to this sample: https://github.com/Azure/azure-sdk-for-js/blob/62662f54163b5ee41cb64a2610a1b65276b59988/sdk/storage/arm-storage/samples-dev/storageAccountsCheckNameAvailabilitySample.ts#L31
const client = new StorageManagementClient(credential, subscriptionId);
const result = await client.storageAccounts.checkNameAvailability(
accountName
);
I want to authenticate to Odoo from an express application using token. I am using odoo-xmlrpc node module to connect Odoo with
my express app. Odoo requires users of the API to be authenticated before they can use any other API. And this node module provides this function
const odoo = new Odoo({
url: config.odooUrl,//odoo url
db: config.odooDB,//odoo db path
username: "john#gmail.com",
password: "john_pass123"
});
odoo.connect(function(err, uid) {
if (err) {
errors.auth = "invalid cridentials";
return res.status(400).send(errors);
}
//execute something from/to odoo server
})
The problem is, I have to enter the user's credentials every time I want to execute an Odoo command. And if I store the user's password it would be stored as a plain text.
My question is, is their token-based authentication to Odoo that can be used through API. Or any other alternative solution to my problem
Currently in Odoo unfortunatelly there is no good solution to this. There is work in progress for support for api token access and 2-factor authentication in this pull request: https://github.com/odoo/odoo/pull/33928.
There are also multiple Odoo rest api modules in app store that support token authentication. You can find these with seach ”rest api” or ”token”. To me none of these have been perfect for my use-cases. I look forward to get native support for this in Odoo Community.
I am using PushSharp library. I am able see deviceToken in the sample code https://github.com/Redth/PushSharp
Can anybody help me how to get that ? PushSharp sample code doesn't explain that
apnsBroker.QueueNotification (new ApnsNotification {
DeviceToken = deviceToken,
Payload = JObject.Parse ("{\"aps\":{\"badge\":7}}")
Same for Android, How can I get the Registration ID's
foreach (var regId in MY_REGISTRATION_IDS) {
// Queue a notification to send
gcmBroker.QueueNotification (new GcmNotification {
RegistrationIds = new List<string> {
regId
},
Data = JObject.Parse ("{ \"somekey\" : \"somevalue\" }")
});
}
I am sending push notification via my service layer which is developed using webapi. Please suggest.
The deviceToken (aka Registration Token) is generated on the client app side.
For GCM - Android, to retrieve the registration token, you'll have to call InstanceID.getToken(). See the official documentation -- Setup a GCM Client on Android:
For GCM - iOS, something similar needs to be done (with further settings needed to connect with APNs). See the official documentation -- Setup a GCM Client on iOS. The guide can be adjusted for Objective-C or Swift.
With that said, the code you referred to is under the section labeled APNS Sample Usage, so I guess it's also safe to refer to this post. Or directly from the Apple Developer site if you plan to directly use APNs without GCM.
PS: If you intend to use GCM, I would strongly recommend that you proceed with using the newer version, which is firebase-cloud-messaging. Official docs here.
I have Firebase storage bucket and I would like to use Node.js Google-cloud notification API in order to listen to changes in the storage.
What I have so far:
const gcloud = require('google-cloud');
const storage = gcloud.storage({
projectId: 'projectId',
credentials: serviceAccount
});
const storageBucket = storage.bucket('bucketId');
Now from what I understand I have to create a channel in order to listen to storage changes.
So I have:
const storageBucketNotificationChannel = storage.channel('channelId', 'resourceId');
This is the threshold where the docs stop being clear, as I can't figure out what channelId a resourceId stand for.
Nor do I understand how to declare listening to channel changes itself. Are there any lifecycle-type methods to do so?
Can I do something like?
storageBucketNotificationChannel.onMessage(message => { ... })
Based on the existing documentation of the Google Cloud Node.js Client and the feedback from this Github issue, there is presently no way for the node client to create a channel or subscribe to object change notifications.
One of the reasons being that the machine using the client may not necessarily be the machine on which the application runs, and thus a security risk. One can still however, subscribe to object change notifications for a given bucket and have notifications received a Node.js GAE application.
Using Objects: watchAll JSON API
When using gsutil to subscribe, gsutil sends a POST request to https://www.googleapis.com/storage/v1/b/bucket/o/watch where bucket is the name of the bucket to be watched. This is essentially a wrapper around the JSON API Objects: watchAll. Once a desired application/endpoint has been authorized as described in Notification Authorization, one can send the appropriate POST request to said API and provide the desired endpoint URL in address. For instance, address could be https://my-node-app.example.com/change.
The Node/Express application service would then need to listen to POST requests to path /change for notifications resembling this. The application would then act upon that data accordingly. Note, the application should respond to the request as described in Reliable Delivery for Cloud Storage to retry if it failed or stop retrying if it succeeded.