API Authentication Issues
I am trying to build an integration to send encrypted emails through ShareFile, but I cannot successfully complete the first step, getting the authentication code.  I'm trying to follow the steps on the OAuth2 Getting Started Guide (https://api.sharefile.com/gettingstarted/oauth2).  Using the first endpoint, whether I pass 'token' or 'code' as response_type and whether I use POST or GET, the return text is an HTML representation of the ShareFile login page, rather than a JSON string with the requested token or code.  The status code is 200.token_url = 'https://secure.sharefile.com/oauth/authorize?response_type=token&client_id=' & sf_client_id & '&redirect_uri=' & sf_redirectSet hReq = CreateObject('MSXML2.ServerXMLHTTP.6.0')With hReq .Open 'POST', token_url .setRequestHeader 'Content-type', 'application/x-www-form-urlencoded' .SendEnd WithIf I try a different endpoint, as found in the cURL sample code (https://api.sharefile.com/samples/curl), I receive the error 'Invalid request; missing 'grant_type'.' though the query string clearly contains grant_type.token_url = 'https://mycompany.sharefile.com/oauth/token?grant_type=password&client_id=' & sf_client_id & '&client_secret=' & sf_secret & '&username=' & sf_user & '&password=' & sf_pwdI've tried encoding and sending the parameters as a JSON payload, which also doesn't work.  So what is the correct endpoint to get an authentication code or token?  What parameters do I need to pass? Thanks

  • I'm attempting to run the example code at: https://api.sharefile.com/samples/curl:  curl -X POST 'https://mycompany.sharefile.com/oauth/token' -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=password&client_id=myclient-id&client_secret=myclient-secret&username=my@user.name&password=mypassword'   My account has 2FA enabled, and I've generated an app password. I've tried that app password (both with spaces and without spaces), but I always get an 'Invalid username or password' response:{'error':'invalid_grant','error_description':'invalid username or password'}   I've tried every permutation I can think of with the following options: - Username: user@domain.com, domain/user@domain.com (per FTP settings), and FTP-specific username - Password: my app-specific password, my app-specific password with spaces removed, my actual password   Note, the app-passwords work just fine when I try to connect with an FTP client.
  • Thanks, Sam!  That's exactly what we ended up doing, as well.  As you said, the API docs don't cover that scenario, but our tech lead figured it out and got me the necessary credentials.
  • Hi,   I hope this helps because it sounds very similar to the issue I had when trying to do this. My issue was that our company's Sharefile account has 2-factor authentication set up so I needed to create an 'app specific password' via my account and use that instead (bypasses 2FA).   https://support.citrix.com/article/CTX277723   This is what I needed to do when running this as an HTTP request through Power Automate for reference -  but my issue was just requiring the app specific password due to 2FA screwing up the request (a scenario that is not covered in that API documentation I think):   URI: https://<company>.sharefile.com/oauth/token   Headers: Content-Type: application/x-www-form-urlencoded   Body: grant_type=password&client_id=<client_id>&client_secret=<clientsecret>&username=<your_sharefile_username>&password=<app_specific_password>
This question is closed.