I’m trying to authenticate with OAuth 2.0 and I keep getting 401 unauthorized errors. I know for sure that I’m using my correct Client ID and Client Secret, so I’m not sure what’s going wrong.
OAuth authentication not working
Best answer by ostefaniuk
Summary: the problem @user79 is reporting occurred with an attempt to use Transloadit with Companion integrated with Uppy component in a Vue + PHP project, with Box Custom app with oAuth 2.0.
I tried to recreate the behaviour using a simplified code sample. I was able to successfully log in to Box with Uppy, but once added the Transloadit with Companion oAuth the process failed. Here is the code I used:
1234Uppy+Transloadit sample app 56  href="https://releases.transloadit.com/uppy/v3.10.0/uppy.min.css"7  rel="stylesheet"8/>910    import {11    Uppy,12    Dashboard,13    ImageEditor,14    RemoteSources,15    Transloadit,16  } from 'https://releases.transloadit.com/uppy/v3.10.0/uppy.min.mjs'17  const uppy = new Uppy()18    .use(Transloadit, {19      waitForEncoding: true,20      alwaysRunAssembly: true,21      assemblyOptions: {22        params: {23          template_id: 'TRANSLOADIT_TEMPLATE_ID',24          auth: {25            key: 'TRANSLOADIT_KEY',26          },27        },28      },29    })30    .use(Dashboard, { trigger: '#browse' })31    .use(ImageEditor, { target: Dashboard })32    .use(RemoteSources, {33      companionUrl: 'COMPANION_URL',34    })35    .on('complete', ({ transloadit }) => {36      console.log(transloadit)37      transloadit.forEach((assembly) => {38        console.log(assembly.results)39      })40    })41    .on('error', (error) => {42      console.error(error)43    })44  45464748    49505152
Errors I’m getting are:
401 on transloadit url and after granting access to Box I get:
1Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').2
Box recognises the login and sends email notification to the user about this action. I contacted the Transloadit support and they are currently working on the fix in the Uppy source code. Please follow this thread for more details and status: https://github.com/transloadit/uppy/pull/4681 [github.com]
Cheers,
Olga
Reply
Login to the community
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.