mgalindo | 2019-05-20 18:55:32 UTC | #1
Hi Everyone, im trying to download an attachment file server side, i already have the url of the attachment, my problem is when i request the url of the file, instead of the file i receive the login page in my response, im aware that purecloud is asking credentials, but i dont know how can give the permissions and go direct to the download url.
I've tried this on nodejs and .net
the response i get this, tks
<meta name="web-auth-service/config/environment" content="%7B%22modulePrefix%22%3A%22web-auth-service%22%2C%22environmen t%22%3A%22production%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22 %3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3A%7B%22Date%22%3Afalse%7D%7D%2C%22APP%22%3A%7B%22name%22%3A%22web-auth-service%22%2 C%22version%22%3A%222.20.0+b4728a32%22%7D%2C%22bootstrap%22%3A%7B%22attemptCountKey%22%3A%22pcAuth-reloadAttempts%22%2C% 22maxAttempts%22%3A3%7D%2C%22localeCookie%22%3A%7B%22name%22%3A%22pcAuth-userPrefLangTag%22%2C%22legacyName%22%3A%22pcAu th-userPrefLocale%22%2C%22expirationDays%22%3A90%7D%2C%22lockOutMinutes%22%3A5%2C%22autoDirect%22%3A%7B%22on%22%3Afalse% 2C%22url%22%3Anull%2C%22protocol%22%3A%22https%22%2C%22hostPrefix%22%3A%22apps%22%2C%22pathname%22%3A%22/architect/%22%7 D%2C%22restoreOrgNameCookie%22%3A%22pcAuth-prevOrgName%22%2C%22restoreOrgNameCookieExpirationDays%22%3A90%2C%22helpSyste m%22%3A%7B%22signUpUrl%22%3A%22https%3A//apps.mypurecloud.com/signup/%23/account%22%2C%22linkBase%22%3A%22http%3A//help. mypurecloud.com%22%2C%22i18nLinkBase%22%3A%22http%3A//help.mypurecloud.com/redirect%22%7D%2C%22apps%22%3A%7B%22baseUrl%2 2%3Anull%2C%22baseProtocol%22%3A%22https%22%2C%22baseHostPrefix%22%3A%22apps%22%2C%22pathnames%22%3A%7B%22collaborate%22 %3A%22/directory%22%2C%22communicate%22%3A%22/directory/%23/search%22%2C%22engage%22%3A%22/contact-center%22%2C%22archit ect%22%3A%22/architect%22%2C%22admin%22%3A%22/admin%22%2C%22collaborateBundle%22%3A%22/directory%22%7D%7D%2C%22exportApp licationGlobal%22%3Afalse%7D" /> <script src="/assets/intl/intl.min-50b782c1f6d9a43411a8603a5a3d9234.js" integrity="sha256-syHhPttPabh44mVQM5ApckIpJn jHrfamoBiE/tmh+Kc= sha512-yyMXGr0VEGFF3Gkso4zm7QyS0OZk0cg2EloVSyABaD0pcKScoI+FKJQibRTXhVr2JubnulNNCZxTw59cGSqENg==" ></s cript> <script src="/assets/intl/locales/en-us-a53ee708f8f05d570a3095cbc9cec948.js" integrity="sha256-2p6FY8PWvyhgctwbeDZc+ u6w+8bsg9cKdjmGq3aWWD8= sha512-ypUJzoM4T4mLVfE2txsFxmB4nz8t05kTWUog+wk22vcNpv0qBDDosGkrJf1u1HIvIsKH4bFsOEFlU3imKeOFQA=="
</script>
<link href="//fonts.googleapis.com/css?family=Lato:400" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="/assets/vendor-d41d8cd98f00b204e9800998ecf8427e.css" integrity="sha256-47DEQpj8HBSa+/TI mW+5JCeuQeRkm5NMpJWZG3hSuFU= sha512-z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+Sfa Pg==" > <link rel="stylesheet" href="/assets/web-auth-service-e2a654ae0fe1e32824fc5eaa3f9db3e1.css" integrity="sha256-4OL5ei 4Vu9s+2dtPEQYhfqiAMLG1nhoH+OiNDyROJmo= sha512-9bJqvXvbG8JFqi6p8ZPodguJFO1jJwiu2YcmHDjSKmF1kwgia5qFJWnyORwLZeCUb71P0q95sZ Krt598WhEUNA==" >
</head> <body>
<script src="/assets/vendor-a7339bcda1e66254983845167e4c0a26.js" integrity="sha256-BrUmKDyQozF6vczWc55eh0vPVKJ/Q06bD OzGr3mWhKg= sha512-QGPMZQF+/ge4ppBcztcar0dv/sB/AaAb7lF/cm7URNQ/5yAdzIfQVP14aLIse+pp0pzKNCgIVSl4cepvKjIukw==" ></script> <script src="/assets/web-auth-service-394e044832d2464e9d0b13ec20721394.js" integrity="sha256-hQdJgA3M5qIvW8kEqzeUZk0 Lk1O2/A4Qy1AEHSonNxc= sha512-wqLpTT5OPulI2VlhEC4N9VQnB0gNRiLKJqyh3U6fafVS1F2ZzD8fxTPemqplL98ariZV7acwNXPf4oUUnTFiBA==" > </script>
</body> </html>
tim.smith | 2019-05-20 19:01:25 UTC | #2
Make sure you're sending the standard authorization header with your auth token with the download request. If you don't provide a valid auth token, you'll get the login page.
mgalindo | 2019-05-20 19:08:35 UTC | #3
Hi Tim, sorry im a little lost here, this is my request, im using client credentials grant, should i sent the request with the token instead of this?
var auth = "Basic " + new Buffer(clientId + ":" + clientSecret).toString("base64"); const options = { method: 'GET', uri: 'https://api.mypurecloud.com/api/v2/downloads/ddc98260', headers: { "Authorization":auth } }
tim.smith | 2019-05-20 19:30:44 UTC | #4
Yes, you should be sending the auth token with the request in the same manner you make any other authenticated request to the API. Your example is only valid when first obtaining an auth token for client credential and auth code grants; it is not valid for making authenticated API requests. See Client Credentials - Use the access token.
mgalindo | 2019-06-04 22:33:49 UTC | #5
Thanks i resolved my problem, with your answer!
system | 2019-07-05 22:33:51 UTC | #6
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 5202