cancel
Showing results for 
Search instead for 
Did you mean: 

I get "invalid grant type" when requesting a bearer token from /puboauth/token

I get "invalid grant type" when requesting a bearer token from /puboauth/token

Hello!  I've created a test API account, and received my key.  My first order of business is to get a bearer token, naturally.  When I POST using my usual HTTP methods (using C#) I get just "401 Unauthorized", so I tried using curl as described in the man page.  I've matched everything in the example, aside of course from entering my own creds, client ID, and URL, but I get "invalid grant type" - despite having "-d grant-type=password" in the parameters:

curl -v --request POST
-H "Content-Type: application/x-www-form-urlencoded"
-d grant-type=password -d username=me@mycompany.com -d password=xyz
-d client_id=xyz https://mycompany.egnyte.com/puboauth/token

Quoting or not quoting the password and the word "password" after grant-type has made no difference so far.  The one thing that stands out is that my user name includes an ampersand, but using %40 in place does not help.

Can anyone see what I'm doing wrong?  Thank you!

Labels (1)
Tags (1)
0 Kudos
5 Replies
Moderator Nars_Support
Moderator

Re: I get "invalid grant type" when requesting a bearer token from /puboauth/token

Hi @Jon of All Trades it may be best to contact our API Support team directly at api-support@egnyte.com for further assistance with this issue.

In the e-mail, please provide the Main API key you attempted to generate a bearer token with, so we may inspect the API key configuration via our dashboard.

You may also refer to the common [Error Codes] published in the Internal Application - Authentication section of our API documentation: https://developers.egnyte.com/docs/read/Public_API_Authentication#Internal-Applications

Regards,
Nars

0 Kudos
Highlighted

Re: I get "invalid grant type" when requesting a bearer token from /puboauth/token

I did trade some e-mails with support, but he was useless; his only suggestion was to use a different user name, which is not the one I use to log in.  It didn't work any better.

0 Kudos
Moderator Nars_Support
Moderator

Re: I get "invalid grant type" when requesting a bearer token from /puboauth/token

@Jon of All Trades I managed to look up the Support ticket, and wanted to make the additional recommendations:

1. Per our API Documentation, one of the authentication requirements is an Egnyte <username

Please note that our WebUI login accepts either username or e-mail address format, but for API authentication, you must use the username (e.g. jalltrades) format explicitly

2. As noted in the common [Error Codes] found in the link I provided, and from past experience, a 403 Error for INVALID_USERNAME_OR_PASSWORD is usually related to special characters within the password itself. 

Try simplifying your password to alphanumerical characters along with the <username> format, and check if the issue persists. 

Regards,
Nars

0 Kudos

Re: I get "invalid grant type" when requesting a bearer token from /puboauth/token

Indeed, you can see "-d username" in the parameters.  The actual user name I'm passing is the same one I use, successfully, when logging in to the Egnyte developers interface (e.g., to retrieve my API key).

If the Egnyte API does not support ampersands in user names, or dashes in passwords, that should be documented.  I've tried URL encoding the user name, but I get the same results.

0 Kudos
Moderator Nars_Support
Moderator

Re: I get "invalid grant type" when requesting a bearer token from /puboauth/token

@Jon of All Trades -d username=me@mycompany.com is not the same as your actual Egnyte username. I'll paste a screenshot in the Support ticket to show the difference.

Egnyte supports special characters with passwords, but we are not able to control 3rd party HTTP libraries, especially when it pertains to API REST clients. Thus, the recommendation to simplify your password to alphanumerical characters when such issue occurs. 

Please take some time to go over the links I've provided for full documentation of our API methods and requirements. 

Regards,
Nars

0 Kudos