Authentication
Egnyte uses OAuth 2.0 for authentication. Before making API calls, you must obtain an access token and include it in the Authorization header of all subsequent requests.
Egnyte supports multiple OAuth 2.0 flows depending on your application type:
- Public applications (partner integrations): Use Authorization Code or Implicit Grant
- Internal applications (customer-built): Use Resource Owner Password Credentials
- Token refresh: Use Refresh Token Flow to obtain new tokens without user interaction
Important: Always cache OAuth tokens in your application. Do not make repeated requests for the same user's token. Treat tokens with the same security as passwords—encrypt them and never store them in browser localStorage.
Token Lifecycle
- Access tokens expire after 30 days
- Refresh tokens can be used to obtain new access/refresh token pairs without user interaction
- Tokens are immediately revoked if a user changes their password or explicitly revokes access
- Your application must handle
401 Unauthorizedresponses and use the refresh token to obtain new credentials
Using Access Tokens
Include the access token in the Authorization header of every API request:
Authorization: Bearer 68zc95e3xv954u6k3hbnma3q
Example Request
curl -i -X GET "https://{domain}.egnyte.com/pubapi/v1/userinfo" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Public Applications
Public applications are built by Egnyte partners for use by multiple customers. Use either the Authorization Code flow (recommended for server-side apps) or Implicit Grant flow (for browser-only apps).
Note: Until your application is approved for production, it will only work on the domain registered in your API key profile.
Authorization Code Flow
The Authorization Code flow is the recommended approach for applications with a server-side component. Tokens are stored securely in your backend and never exposed to the browser.
Step 1: Initiate the Authentication Flow
Redirect the user to the Egnyte OAuth authorization page:
https://{domain}.egnyte.com/puboauth/token?client_id={API_Key}&redirect_uri={Callback_URL}&scope={SCOPES}&state={STATE}&response_type=code
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | The API key provided when you registered your application |
redirect_uri | string | Yes | HTTPS callback URL that matches your registered key configuration (e.g., https://yourapp.com/oauth) |
response_type | string | Yes | Must be code for this flow |
scope | string | No* | Space-delimited list of OAuth scopes. Required for production approval |
state | string | No | Opaque value for CSRF protection and maintaining state between request and callback |
*While technically optional, all third-party applications must scope token requests. Applications will not be approved for production without proper scoping.
Example Request
https://apidemo.egnyte.com/puboauth/token?client_id=x2g35g8gynb5cedas649m4h4&redirect_uri=https://yourapp.com/oauth&scope=Egnyte.filesystem%20Egnyte.link&state=apidemo123&response_type=code
The user will see an authorization page displaying your application information and requesting permission to access their Egnyte account.
Step 2: Handle the Authorization Response
On approval, Egnyte redirects to:
https://yourapp.com/oauth?code=5u3m26mzgfn8nv6antmessr5&state=apidemo123
On denial, Egnyte redirects to:
https://yourapp.com/oauth?error=access_denied&state=apidemo123
Step 3: Exchange the Code for a Token
Make a POST request to exchange the authorization code for an access token:
POST /puboauth/token
Request Body (form-encoded)
Send as application/x-www-form-urlencoded:
| Parameter | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | Your API key |
client_secret | string | Yes | Your API secret (provided with keys issued after January 2015) |
redirect_uri | string | Yes | Must match the redirect URI from Step 1 |
code | string | Yes | The authorization code received in Step 2 |
grant_type | string | Yes | Must be authorization_code |
scope | string | No | Must match the scope from Step 1 if provided |
Example Request
curl -i -X POST "https://{domain}.egnyte.com/puboauth/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ \ -d 'client_id={client_id}&client_secret={client_secret}&redirect_uri={redirect_uri}&code={authorization_code}&grant_type=authorization_code'
Response
200 OK
| Field | Type | Description |
|---|---|---|
access_token | string | OAuth access token valid for 30 days |
refresh_token | string | Token used to obtain new access tokens |
token_type | string | Always bearer |
expires_in | integer | Token lifetime in seconds (2592000 = 30 days) |
Example Response
{
"access_token": "68zc95e3xv954u6k3hbnma3q",
"refresh_token": "46zc95e3xv954u6k3hbnma3f",
"token_type": "bearer",
"expires_in": 2592000
}
Store both tokens securely and encrypted. Never expose them in browser storage.
Enhanced Authentication Service
The Enhanced Authentication Service simplifies the Authorization Code flow by eliminating the need to know the user's Egnyte domain upfront. The user is prompted to provide their domain during the OAuth flow.
Base URLs
| Region | URL |
|---|---|
| Europe | https://partner-integrations.egnyte.com/services/ |
| United States | https://us-partner-integrations.egnyte.com/services/ |
Initiate Enhanced OAuth Flow
Redirect the user to:
{baseUrl}/oauth/code?redirect_uri={clientUri}&client_id={apiKey}&state={state}
The flow redirects to your clientUri with an authorization code. The user's chosen domain is available in the Referer header.
Skip Domain Selection
If you already know the user's domain, skip the domain selection step by adding the domain parameter:
{baseUrl}/oauth/code?redirect_uri={clientUri}&client_id={apiKey}&domain=apidemo.egnyte.com&state={state}
Example Request
https://partner-integrations.egnyte.com/services/oauth/code?redirect_uri=https://example.com/&client_id=x2g35g8gynb5cedas649m4h4&state=STATE
Example Response
Redirects to:
https://example.com/?state=STATE&code=st6b9tzzz5ck48x5yyauswv3
Retrieve the Egnyte domain from the Referer header in the final redirect.
Implicit Grant Flow
The Implicit Grant flow is designed for browser-based applications that cannot securely store a client secret. The access token is returned directly in the URL fragment.
Warning: This flow exposes the access token to the user. Use Authorization Code flow if your application has a backend component.
Step 1: Initiate the Authentication Flow
Redirect the user to:
https://{domain}.egnyte.com/puboauth/token?client_id={API_Key}&redirect_uri={Callback_URL}&scope={SCOPES}&state={STATE}&response_type=token
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | Your API key |
redirect_uri | string | Yes | HTTPS callback URL matching your registered configuration |
response_type | string | Yes | Must be token for this flow |
scope | string | No* | Space-delimited list of OAuth scopes |
state | string | No | Opaque value for CSRF protection |
*Required for production approval.
Example Request
https://apidemo.egnyte.com/puboauth/token?client_id=x2g35g8gynb5cedas649m4h4&redirect_uri=https://yourapp.com/oauth&scope=Egnyte.filesystem%20Egnyte.link&state=apidemo123&response_type=token
Step 2: Handle the Response
On approval, Egnyte redirects to:
https://yourapp.com/oauth#access_token=68zc95e3xv954u6k3hbnma3q&token_type=bearer&state=apidemo123
On denial, Egnyte redirects to:
https://yourapp.com/oauth#error=access_denied&state=apidemo123
Note: The Implicit Grant flow does not return a refresh token. Access tokens expire after 30 days and cannot be refreshed.
Internal Applications
Internal applications are built by Egnyte customers for use within their own organization. Use the Resource Owner Password Credentials flow to obtain tokens.
Resource Owner Password Credentials Flow
This flow allows internal applications to obtain tokens by exchanging user credentials directly.
Warning: Only use this flow for trusted, internal applications. Never use it for public applications.
Request
POST /puboauth/token
Request Body (form-encoded)
Send as application/x-www-form-urlencoded:
| Parameter | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | Your API key |
client_secret | string | Yes* | Your API secret (required for keys issued after January 2015) |
username | string | Yes | Egnyte username |
password | string | Yes | Egnyte password |
grant_type | string | Yes | Must be password |
scope | string | No | Space-delimited list of OAuth scopes |
*Required if your key was issued after January 2015.
Example Request (cURL)
curl -i -X POST "https://{domain}.egnyte.com/puboauth/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ \ -d 'client_id={client_id}&client_secret={client_secret}&username={username}&password={password}&grant_type=password'
Response
200 OK
| Field | Type | Description |
|---|---|---|
access_token | string | OAuth access token valid for 30 days |
refresh_token | string | Token used to obtain new access tokens |
token_type | string | Always bearer |
expires_in | integer | Token lifetime in seconds (2592000 = 30 days) |
Example Response
{
"access_token": "68zc95e3xv954u6k3hbnma3q",
"refresh_token": "46zc95e3xv954u6k3hbnma3f",
"token_type": "bearer",
"expires_in": 2592000
}
OAuth Scopes
OAuth scopes restrict a token's access to specific APIs. By default, tokens have global access to all APIs. You should always scope tokens to only the APIs your application needs.
Important: Third-party applications must use scopes. Applications will not be approved for production without proper scoping or a valid justification for global access.
Specifying Scopes
Pass the scope parameter as a space-delimited list:
scope=Egnyte.filesystem Egnyte.link
For Authorization Code and Implicit Grant flows, include scope in the query string. For Resource Owner flow, include it in the form-encoded request body.
Available Scopes
| Scope | APIs Included |
|---|---|
Egnyte.filesystem | File System, Search, Comments, Events, Folder Options, User Insights, Trash, Workflows |
Egnyte.ai | AI |
Egnyte.permission | Permissions |
Egnyte.link | Links |
Egnyte.projectfolders | Project Folders |
Egnyte.bookmark | Bookmarks |
Egnyte.user | User Management |
Egnyte.group | Group Management |
Egnyte.audit | Audit Reporting |
Egnyte.salesforce | Salesforce Integration |
Egnyte.launchwebsession | Embedded UI |
Egnyte.controlleddocs | Controlled Document Management |
Egnyte.etmf | eTMF |
Egnyte.documentportal | Document Portal |
Egnyte.uploadrequests | Upload Requests |
Egnyte.webhooks | Webhooks |
Egnyte.integrations | Integrations |
Egnyte.sign | Egnyte Sign |
User-Facing Scope Display
When using public application flows, users see a list of permissions based on requested scopes. Requesting only necessary scopes increases the likelihood of user approval.
Example: No scopes specified
The authorization dialog shows:
This application will be able to:
- Read, write and delete files/folders
- Create, update and delete users
- Generate audit reports
- Create and delete file/folder links
- Add, update, delete and report on folder permissions
Example: Scoped request
scope=Egnyte.filesystem Egnyte.link
The dialog shows only relevant permissions for File System and Links APIs.
Get User Info for an OAuth Token
Retrieve user information associated with a given OAuth token.
Request
GET /pubapi/v1/userinfo
Example Request (cURL)
curl -i -X GET "https://{domain}.egnyte.com/pubapi/v1/userinfo" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Response
200 OK
| Field | Type | Description |
|---|---|---|
id | integer | User ID |
first_name | string | User's first name |
last_name | string | User's last name |
username | string | Egnyte username |
Example Response
{
"id": 123,
"first_name": "Test",
"last_name": "User",
"username": "test"
}
Revoke an OAuth Token
Revoke access for an OAuth token. Revoking an access token also revokes its associated refresh token.
Important: When an access token is revoked, the associated refresh token is also revoked and cannot be used to mint new tokens.
Request
POST /pubapi/v1/tokens/revoke
Request Body (form-encoded)
Send as application/x-www-form-urlencoded:
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | The access or refresh token to revoke. If an access token is provided, its refresh token is also revoked |
client_secret | string | Yes | Your API secret |
Example Request (cURL)
curl -i -X POST "https://{domain}.egnyte.com/pubapi/v1/tokens/revoke" \ -H "Content-Type: application/x-www-form-urlencoded" \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -d 'token={access_token}&client_secret={client_secret}'
Response
200 OK
Returns an empty response body on success.
Refresh Token Flow
Use the Refresh Token flow to obtain a new access token without requiring user interaction. This allows your application to maintain continuous access after the initial access token expires.
Step 1: Request New Tokens
POST /puboauth/token
Request Body (form-encoded)
Send as application/x-www-form-urlencoded:
| Parameter | Type | Required | Description |
|---|---|---|---|
client_id | string | Yes | Your API key |
client_secret | string | Yes | Your API secret |
grant_type | string | Yes | Must be refresh_token |
refresh_token | string | Yes | The valid refresh token previously issued to your application |
Example Request (cURL)
curl -i -X POST "https://{domain}.egnyte.com/puboauth/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ \ -d 'client_id={client_id}&client_secret={client_secret}&grant_type=refresh_token&refresh_token={refresh_token}'
Step 2: Handle the Response
On success, Egnyte returns a new access and refresh token pair:
{
"access_token": "68zc95e3xv954u6k3hbnma3q",
"refresh_token": "46zc95e3xv954u6k3hbnma3f",
"token_type": "bearer",
"expires_in": 2592000
}
On failure (invalid refresh token):
{
"message": "Invalid Refresh Token"
}
Store both tokens securely and encrypted. Never store them in browser localStorage.
Error Codes
| Status | Error Code | Description | Resolution |
|---|---|---|---|
| 400 | APIKEY_FOR_IMPLICIT | API key is configured only for Implicit Grant flow | Use the Implicit Grant flow or contact api-support@egnyte.com to convert your key |
| 400 | INTERNAL_ERROR | OAuth request has exceeded rate limit quota | Check your application logic to ensure tokens are being properly cached |
| 400 | INTERNAL_ERROR (null message) | Invalid parameter name or syntax error | Verify all parameter names and request format |
| 400 | GRANT_PASSWORD | grant_type must be password for Resource Owner flow | Set grant_type=password |
| 400 | RESOURCE_FLOW_ISNULL | Missing username or password | Ensure username and password are included in the request body with correct Content-Type header |
| 401 | INTERNAL_ERROR | No active developer profile found for API key | Verify your API key is correct and properly formatted |
| 403 | INVALID_USERNAME_OR_PASSWORD | Invalid credentials or missing client secret | Verify username, password, and client_secret are correct. Test with a simpler password if using special characters |
Related Resources
- Getting Started — Register your application and obtain API keys
- Best Practices — Rate limiting, error handling, and security recommendations
- File System API — Manage files and folders after authentication
