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 Box
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:
<!DOCTYPE html>
<html>
<head>
<title>Uppy+Transloadit sample app</title>
<link
href="https://releases.transloadit.com/uppy/v3.10.0/uppy.min.css"
rel="stylesheet"
/>
<script type="module">
import {
Uppy,
Dashboard,
ImageEditor,
RemoteSources,
Transloadit,
} from 'https://releases.transloadit.com/uppy/v3.10.0/uppy.min.mjs'
const uppy = new Uppy()
.use(Transloadit, {
waitForEncoding: true,
alwaysRunAssembly: true,
assemblyOptions: {
params: {
template_id: 'TRANSLOADIT_TEMPLATE_ID',
auth: {
key: 'TRANSLOADIT_KEY',
},
},
},
})
.use(Dashboard, { trigger: '#browse' })
.use(ImageEditor, { target: Dashboard })
.use(RemoteSources, {
companionUrl: 'COMPANION_URL',
})
.on('complete', ({ transloadit }) => {
console.log(transloadit)
transloadit.forEach((assembly) => {
console.log(assembly.results)
})
})
.on('error', (error) => {
console.error(error)
})
</script>
</head>
<body>
<button id="browse">Select Files</button>
</body>
</html>
Errors I’m getting are:
401 on transloadit url and after granting access to Box I get:
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.