I am trying to connect hangouts chat API with NodeJS but did not find any documentation related to Oauth in NodeJS, without which I can not connect to APIs. There is a code in Python but is there any thing in Node so that we can do the API call from front end it self.
The Oauth flow is the same for all Google APIs
If there is a quickstart for a specific API in a specific language missing, you can use one from another API.
For example, there is a Node.js quickstart for the Drive API
You can take it as a base and have to modify only 2 things:
Modify
const SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly'];
by specifying the scopes you are going to use, for example
https://www.googleapis.com/auth/chat
For building the service, modify
const drive = google.drive({version: 'v3', auth});
to
const chat = google.chat({version: 'v1', auth});
Mind that depending on the application, you might need to use a service account
The documentaiton about implementing a service account in node.js can be found here
Related
I'm trying to build an app using GPT3 APIs and would like users to login to the app using OpenAI's credentials so as to use their account for GPT3 APIs requests, however there is no support for 3rd party login so far in Open AI's documentation. Anyone has ideas on how this can be done?
As far as I'm concerned Open ai does not have an oauth API like Google (for example). The only idea that occurs to me is to ask the user for their Open ai Api key and make the requests through that key
i have been trying to send whatsapp messages using cloud api, but its expecting to enable whatsapp_business_messaging permission which is by default disabled when associating with any app that has been created.
https://developers.facebook.com/docs/whatsapp/cloud-api/get-started#get-access-token.
i didn't find any documentation pertaining to enable the above mentioned permission. Kindly assist
Edited
WhatsApp cloud API is Now Public!
According to their docs,
To start using it for development prepose
Register as a Meta Developer
Enable two-factor authentication for your account
Create a Meta App: Go to developers.facebook.com > My Apps >
Create App. Select the "Business" type and follow the prompts on
your screen.
From the App Dashboard, click on the app you would like to connect
to WhatsApp. Scroll down to find the "WhatsApp" product and click
Set up.
the onboarding process performs the following actions:
our App is associated with the Business Manager that you chose
A WhatsApp test phone number is added to your business. You can use this test phone number to explore the WhatsApp Business Platform
without registering or migrating a real phone number.
for more info please refer to whatsapp cloud getting started docs
Yes, WhatsApp Cloud API is now public.
With the Cloud API, businesses can directly get access to WhatsApp Business API from Facebook, in minutes.
For more info check out this WhatsApp Cloud API Guide.
I recently made an open-source python wrapper for newly WhatsApp Cloud API to help developers easily get started, You really wanna have a look at it https://github.com/neurotech-HQ/heyoo.
Installation
pip install --upgrade heyoo
Here is the sample code to send a message ;
>>> from heyoo import WhatsApp
>>> messenger = WhatsApp('TOKEN', phone_number_id='104xxxxxx')
>>> messenger.send_template('hello_world', 'your number')
For Javascript developers please have a look into Heyhooh
Installation
npm install heyooh
Here how sending to send messages;
import WhatsApp from heyhooh
let messenger = new WhatsApp('TOKEN', phone_number_id='104xxxxxx')
messenger.send_template("hello_world", "255757xxxxxx")
For PHP Developers whatsappcloud-php
Installation
composer require zepson/whatsappcloud-php
Here how the code to send a message;
<?php
require_once 'vendor/autoload.php';
use zepson\Whatsapp\WhatsappClass;
$token = 'YOUR_META_WHATSAPP_APP_ACCESS_TOKEN';
$phone_number_id = '10726082513218961';
//send message
$tsap = new WhatsappClass( $phone_number_id, $token);
$sendtsap = $tsap->send_template('hello_world', '255654485755');
print_r($sendtsap);
I'm trying to integrate our web app with voice/video call feature by using Agora. I have read the documentation on their side, but I have not found any rest api for web sdk to create channel. Basically, when a user joins a channel, we have to pass in the app id, token, and channel name. I know that we can create channel in agora dashboard, but I'm looking for a dynamic way, where we can trigger a REST api to do it. Any help would be greatly appreciated. Thank you.
You can deploy your own token server, that will give you the token based on a channel name and uid.
Here's a pre-built server that you can deploy to Heroku in 2 clicks.
I have been able to build a node js to generate agora io token. It is hosted in heroku. The source code can be found here:
https://github.com/Hoang-Minh/partie-agora-token-generator
Here are the endpoint that you can call to generate a token:
api/agora/rtcToken/:tokenType where
tokenType can be either uid or account, depends on what you need.
The default expiration time that I have is 24 hours.
In the company I am working for, we provide a solution for other companies, and we want each company to have a separate instance of that solution, this includes a separate database instance, the database is Firebase, this choice of creating a new separate instance is required due to data privacy laws of the country we work in.
I am working on a script that when triggered by the new client SignUp, it starts the creation of new solution instance, including the creation of the new Firebase project, and I am using firebase-tools CLI and gcloud CLI.
The project creation happens correctly, and the admin account is created, the only remaining thing is to allow the admin to be able to login to the new Firebase project. This is usually done manually from the Firebase web console, by enabling a login provider, an Email&Password login provider in my case. This part of the process is so not automated, because I can't find the command that I should pass to Firebase-tools or gcloud ClI to enable a login provider in a Firebase project.
What is a command that you can pass to Firebase tools or to gcloud CLI , to change firebase project confguration to enable a signin provider ? signin usng Email&Passsword in this case .. Or is there a way to do it programmatically using Google client libraries ?
From looking at the REST API for the Google Identify Platform, I don't immediately see a call that shows email+password authentication. Unless I'm overlooking something this means it might not be possible to programmatically enable this provider through a public API.
From checking what the Firebase console does, it seems it handles the provider configuration through the https://identitytoolkit.clients6.google.com/admin/v2/projects/<projectid>/config endpoint, but I'm not sure that is part of the public API.
This seems possible now via Identity Toolkit API. The v2.projects REST resource has updateConfig method, and the Config contains SignInConfig which have the Email property.
I am developing a frontend with react-native, and I need use static maps form Google or MapBox. To store Api key at develop time I am using a .env file with react-native-config but their readme say:
Keep in mind this module doesn't obfuscate or encrypt secrets for
packaging, so do not store sensitive keys in .env. It's basically
impossible to prevent users from reverse engineering mobile app
secrets, so design your app (and APIs) with that in mind.
So, is there some way to obfuscate Api keys on react-native (for Android and IOS)?
Or the only way is create an endpoint at the backend doing proxy functions to add here the api key, something like:
import express, { Application } from "express";
import * as https from "https";
const app: Application = express();
app.get("/map", (request, response) => {
const params: string = "Get the params from request";
https.request(`https://maps.googleapis.com/maps/api/staticmap?key=${process.env.API_KEY}&${params}`, (result) => {
result.pipe(response, { end: true });
});
});
I can see several drawback, I will consume more bandwidth from my hosting and I will slow down of my application (first a request from the frontend to the backend, after a request from the backend to Google static maps, after the backend gets the response from Google maps and at end the frontend gets the response from the backend)
PS: Keep in mind I am talking about Google maps static and not google maps sdk Android or google maps sdk IOS.
MapBox have a good support. So after asking them here is the response:
Unfortunately, the proxy approach you've described is a violation of
our Terms of Service.
I want to make sure you have seen our guide for using Mapbox
securely. It includes a lot of great tips and best practices for
managing your account.
In our experience, cycling tokens on the customer side paired
with a general awareness of what's happening (by monitoring your
account statistics) has been sufficient to control and limit access
most of the time. If you're in need of frequent, programmatic access
token rotation, you can utilize our Tokens API for that.
All this being said, restricting tokens by app id is on our radar as
it's a common request we receive. Our engineering team is hard at work
to make a whitelisting feature possible for our customers. Until then,
if you ever have questions about your statistics or are seeing
unexpected stats. We're always happy to work with you and can look
into the any concerning usage patterns for you.
If you have other questions about your account statistics or invoices,
be sure to check out our Statistics FAQs.
Hope this helps!