Dropbox integration for application - node.js

I'm super confused on how to create proper integrations from my web app to dropbox.
I want to list and create files from within the application.
I'm using NodeJS and the Dropbox JS SDK, so far so good.
But I'm not understanding on how to set up the authentication/authorization.
I've created a Dropbox application, generated an API key.
I pass the API Key in my call to the dropbox SDK:
var dbx = new Dropbox({
accessToken:
"ABC_MY_KEY_123"
});
dbx
.filesListFolder({ path: "" })
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
});
I'm getting the following error back:
status: 400,
[0] error: 'Error in call to API function "files/list_folder": This API function operates on a single Dropbox account, but the OAuth 2 access token you provided is for an entire Dropbox Business team. Since your API app key has team member file access permissions, you can operate on a team member\'s Dropbox by providing the "Dropbox-API-Select-User" HTTP header or "select_user" URL parameter to specify the exact user https://www.dropbox.com/developers/documentation/http/teams
So, should my App have it's own user and then authenticate using that user?
Or is there an API which is Dropbox business wise ?

When first registering a Dropbox app, you choose between either the "Dropbox API" or the "Dropbox Business API". The former will give you an app for connecting to individual user accounts, and the latter will give you an app for connecting to entire Business teams.
The filesListFolder method you're trying to use is a user-specific method, i.e., it operates on a specific user account, and not a Business team entirely.
The error message is indicating that your access token is for a Business team, and so it doesn't know which user to operate on.
If you want any user to connect to your app, you should register a "Dropbox API" app instead.
Or, if you do want to connect to entire Dropbox Business teams only (and selected the "team member file access" permission), you can still use the user endpoints with an access token for a Dropbox Business API app. To do so, you need to specify the desired member ID in the selectUser parameter when making your Dropbox object.

Related

how to find from which application user authenticated in firebase authentication

I am working on this project which has
franchise --> website --> jsr_franchise.com
customer --> website --> jsr_customer.com
I am using phone authentication Only.
both use same authentication to login
how do i distinguish wherther user logged in from customer franchise website?
When I use firebase function
exports.new_User_Added = functions.auth.user()
.onCreate(async (user) => {
database.ref(`/accountCreation/${user.uid}/phoneNumber/`).set(user.phoneNumber)
database.ref(`/accountCreation/${user.uid}/TIMESTAMP/`).set(admin.database.ServerValue.TIMESTAMP)
return Promise.resolve()
})
I am able to get phone number and time stamp. But how do I determine? Whether your user used Customer website or franchise website to authenticate.
With Firebase Authentication a user doesn't log in to a specific site, but they log in to the entire Firebase project. No information about what site triggered that log-in is passed to Cloud Functions.
The most common workaround I know of is to pass all the information that is needed to create the user into a callable Cloud Function or HTTP Cloud Function, create the account there, set a custom claim on their profile with the extra information you want to maintain, and only then sign the user in on the client.

GitHub REST API - get current user's enterprise memberships

I've just started using the GitHub REST API, and I'm trying to find a way to retrieve the list of (Cloud) Enterprises the current / authenticated user is a member of - basically the list that appears when you navigate to https://github.com/settings/enterprises in a browser...
... but I'm drawing a complete blank with the documentation at https://docs.github.com/en/rest.
For clarity, I'm authenticating against the API using a Personal Access Token, and I'm trying to retrieve the list of Enterprises for the user the PAT is associated with.
Is there a specific API endpoint that returns this information? Or is there a way to derive it from another endpoint (e.g. getting the list of organisations for the authenticated user and extracting the enterprise details from them somehow)?
I'm currently using the latest OctoKit.net in C# for some other integration with the GitHub API, in case there's a built-in way to do it, but I'll happily send a bare-bones HTTP request to a uri if one exists...

How to have google docs api (nodejs) create an empty doc in a particular google account

I have an express.js application where clients authenticate using a local strategy (passport.js). After that I want them to be able to create empty documents with titles of their wish (I create a new mongoose 'Task' document and set its doclink (Task.doclink) to be the newly created document's public link (https://docs.google.com/document/d/...document_id.../edit)).
I want this new document to be created in a particular google account that I have access to (the clients don't have direct access to it but they can create documents inside it and write to it)
Any suggestions of how I should go about authorization of google API? As per my current research, this seems impossible.
What I would recommend you to use is a service account as the docs say:
A service account is an identity that an instance or an application
can use to run API requests on your behalf.
What it means is that you will be able to have a "bot user" in your express app, which could be the interface between your users and your document.
Docs
You can check more about it in these links:
Creating and managing service accounts.
Authenticating users with Node.js.

React to Error in Technical Profile

We have a working user journey scenario (roundtrip), where user signs up/signs in, gets objectId, and at the end, we call a REST service sending the objectId to receive a custom attribute (uniqueidentifier from an on-premise service) to add it as a custom attribute (extension) in Azure AD.
As said this works fairly well, but we would like to react to errors, when the REST service calls fails (e.g. server is down). Now the user shows up in AD, but it is missing the unique identifier as custom attribute.
Is there a way we can react to errors in the execution of a Technical Profile?
For Example, make another REST call, where we can handle this Error? As per default the user now gets to see a standard error page.
Thx

How to add external service data to currently signed in user in Meteor

I was playing with the loginWithExternalService methods under Accounts and I was sad to find that while you could create new users with one of these services or log in those who already had credentials, there was no way of allowing currently logged in users to augment their methods of authentication so that they could log in with any of the services they have authenticated through. Is there a way of dumping information like a user's FB profile or a user's Twitter url into their existing, currently logged in account? I tried customizing accounts-base but this.userId returns null within it so I cannot do updates to the currently logged in user there.
There should probably be a better API for this, but at the moment (Meteor 0.5.2) the following server code will create a user associated with an Facebook ID.
var newlyCreatedUserId = Accounts.updateOrCreateUserFromExternalService(
'facebook',
{id: FACEBOOK_ID},
{additionalFieldOnUserDocumented: 'foo'}).id
If you dig into the implementation of Accounts.updateOrCreateUserFromExternalService you can see how to add these fields to an existing user.

Resources