egnyte supports multiple methods for authenticating with the Egnyte API. Which one you should use depends on your situation - whether you have admin access, whether you’re running scripts interactively or in automation, and what level of security you need.
This vignette walks through each authentication method, explains when to use it, and shows you how to set it up.
egnyte supports three authentication approaches:
| Method | Best For | Admin Required | Refresh Tokens |
|---|---|---|---|
| API Key | Personal use, simple scripts | Yes (to create key) | N/A |
| OAuth Authorization Code | Interactive use, team environments | No | Yes |
| OAuth Password | Automation, service accounts | No | No |
Let’s look at each one in detail.
This is the simplest approach. You get an API key from your Egnyte admin (or create one yourself if you are the admin), and use it directly.
For details on obtaining and configuring an API key, see
vignette("configuration").
This flow lets you authenticate directly with a username and password, without browser interaction. It’s useful for automation scenarios where you can’t have a human in the loop.
First, configure your OAuth application (same as above):
library(egnyte)
eg_oauth_app(
domain = "your-company",
client_id = "your-client-id",
client_secret = "your-client-secret"
)Then authenticate with username and password:
You probably don’t want passwords in your scripts. egnyte can read credentials from environment variables:
EGNYTE_USERNAME: Your Egnyte usernameEGNYTE_PASSWORD: Your Egnyte passwordIf you’re running interactively and the environment variables aren’t set, egnyte will prompt you to enter your credentials.
The password flow has some limitations compared to the authorization code flow:
Here’s a decision tree:
Do you have an API key or can easily get one? - Yes
→ Use eg_auth() with your API key. Simple and
effective.
Do you need automated, unattended execution? - Yes →
Use eg_oauth_password(). Set credentials in environment
variables.
Are you building for multiple users or want OAuth
benefits? - Yes → Use eg_oauth_authorize(). More
setup, but better for teams.
Regardless of which method you use, egnyte stores your authentication state in R options for the duration of your session:
egnyte.domain: Your Egnyte domainegnyte.api_key: Your API key (if using API key
auth)egnyte.access_token: Your OAuth access token (if using
OAuth)egnyte.refresh_token: Your OAuth refresh token (if
available)egnyte.token_expiry: When your OAuth token expiresThese are cleared when your R session ends. If you want persistent authentication across sessions, use environment variables for your credentials.
A quick note on token lifetimes:
egnyte handles token refresh automatically when using the
authorization code flow. If you’re using the password flow and your
token expires, you’ll need to call eg_oauth_password()
again.
“Invalid API key” error
“Access denied” error
Browser doesn’t open during OAuth
“Token expired” and refresh fails
eg_oauth_authorize() again to get new tokensNow that you understand the authentication options:
vignette("file-transfer")vignette("reading-writing")
Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.
This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.