javascriptonedriveuppy

Uppy and OneDrive integration


When I try to use the OneDrive plugin for Uppy I get error:

AADSTS900144: The request body must contain the following parameter: 'client_id'.

But when I do a request like this:

GET https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope}
  &response_type=code&redirect_uri={redirect_uri}

I get what I need - authorization.

So how do I add the client_id to the request?

I tried with uppy.setMeta but with no sucess.

Code I use at the moment:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="robots" content="noindex">
    <title>Uppy</title>
    <link href="https://releases.transloadit.com/uppy/v1.27.0/uppy.min.css" rel="stylesheet">
</head>
<body>
<div id="drag-drop-area"></div>

<script src="https://releases.transloadit.com/uppy/v1.27.0/uppy.min.js"></script>
<script>

    var uppy = Uppy.Core()
        .use(Uppy.Dashboard, {
            inline: true,
            target: '#drag-drop-area'
        })
        .use(Uppy.GoogleDrive, {target: Uppy.Dashboard, companionUrl: 'http://localhost:3020'})
        .use(Uppy.Dropbox, {target: Uppy.Dashboard, companionUrl: 'http://localhost:3020'})
        .use(Uppy.OneDrive, {target: Uppy.Dashboard, companionUrl: 'http://localhost:3020'})
        

    uppy.setMeta({
        "client_id": "some_id"
    })

    uppy.on('complete', (result) => {
        console.log('Upload complete! We’ve uploaded these files:', result.successful)
    })
</script>
</body>
</html>

Solution

  • I'm leaving the things I did for anyone faceing the same issue:

    set COMPAINON_ONEDRIVE_KEY to the client ID in Azure App registration

    set COMPANION_ONEDRIVE_SECRET to the value of the secret that is generated in Azure

    set COMPANION_ONEDRIVE_DOMAIN_VALIDATION to true

    Make a directory with read/write permissions and add it to docker-compose or what you are using.

    In Azure Portal make sure you are using trial license. Also there make permissions files.read.all, offline_access and User.Read. Expose API with the aformentioned permissions.

    Make sure the Redirect URI is using the same URL as your server that is hosting the Companion like this: <app-address>/onedrive/redirect

    Here is the docker-compose I used:

    version: '3.9'
    
    services:
      uppy:
        image: transloadit/companion
        build:
          context: .
          dockerfile: Dockerfile
        environment:
          - NODE_ENV=development
        volumes:
          - ./output:/app/output
          - ./packages/@uppy/companion/src:/app/src
          - ./packages/@uppy/companion/node_modules:/app/node_modules
          - ./packages/@uppy/companion/nodemon.json:/app/nodemon.json
          - /mnt/uppy-server-data:/mnt/uppy-server-data
        ports:
          - "3020:3020"
        command: "/app/src/standalone/start-server.js --config nodemon.json"
        env_file:
         - .env
    

    Dockerfile is in the repo.