Running code samples in the Developer Guide

Last updated: 2021-12-02 Contributors Byrne Reese
Edit this page

About RingCentral code samples and environment variables

To help developers make use of the many code samples found throughout this Developer Guide, each code sample is designed around the same usage pattern familiar to many developers. Commonly used variables, like your RingCentral application client ID, secret key, server URL and more, are collected together and placed in a config file, that is then loaded into your local environment upon script execution.

This is helpful as developers should know because it keeps your code separate from the preferences ands data that govern your code's behavior. This is how most modern CI/CD system are architected today, and makes it much easier for developers to containerize their code.

Your RingCentral .env file

Each code sample found within this Developer Guide is designed to use the variables found within a .env file to properly configure itself to run.

To begin, copy the contents of the file below and save it to your local development machine in a file named .env. Be sure to place that file within the same directory you will be running your test scripts from. Finally, edit the .env file to set the values of its variables accordingly.

# Create an app in the RingCentral Developer Console. Make sure the app has all permissions enabled.
# Enter in the credentials for this app into the fields below.

# Sandbox
RC_SERVER_URL        = 'https://platform.devtest.ringcentral.com'
# Production
#RC_SERVER_URL        = 'https://platform.ringcentral.com'
RC_CLIENT_ID         = ''
RC_CLIENT_SECRET     = ''

# These credentials are used for password-grant types
RC_USERNAME          = ''
RC_PASSWORD          = ''
RC_EXTENSION         = '101'

# This credential is used for JWT-grant types
RC_JWT               = ''

# Used in messaging/quick-start.py
# This following phone number will receive a test SMS message
SMS_RECIPIENT        = ''

# Used in voice/quick-start.py
# This following phone number will receive a phone call
RINGOUT_RECIPIENT    = ''

# Used in PubNub Quick Start
# The following URL cannot be blank when running the PubNub Quick Start.
# Its value will have no impact on automated test results. 
RC_REDIRECT_URL      = 'http://localhost:5000/oauth2callback'

# Used in voice/call-forwarding.py
# The following phone number will be set as a forwarding number. 
RC_FORWARDING_NUMBER = ''

Finally, run your code sample from the command line as you would normally. The script should read in the values from this file, and set all the local configuration properties accordingly.

.env file security

Your .env files contain sensitive information. Here are some tips to help keep them secure. * Keep .env files out of source control. Don't check in .env files to source control. Consider using a vault instead, and add .env files to your .git-ignore (or equivalent) file. * Don't make .env files web-accessible. Do not deploy your .env file to a directory that is accessible via http. Keep these files out of your web root folder.

Rate this page: