Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add C# language tab and corresponding content in Getting Started section #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: RingCentral API Reference
language_tabs:
- http
- javascript
- csharp : C#

toc_footers:
- <a target="_blank" href='https://developers.ringcentral.com/sign-up.html#/'>Sign Up for RingCentral for Developers</a>
Expand Down Expand Up @@ -312,6 +313,13 @@ var rcsdk = new RCSDK({
});
~~~

~~~ csharp
using RingCentral;

var rcsdk = new SDK("yourAppKey", "yourAppSecret", "RC_SERVER_SANDBOX",
"yourAppName Name","yourAppVersion");
~~~

The SDK is represented by the global RCSDK constructor. Your application must create an instance of this object.

In order to bootstrap the RingCentral JavaScript SDK, you have to first get a reference to the Platform singleton and then configure it. Before you can do anything using the Platform singleton, you need to configure it with the server URL (this tells the SDK which server to connect to) and your unique API key (this is provided by RingCentral's developer relations team).
Expand All @@ -326,6 +334,10 @@ This instance will be used later on to perform calls to API.
var platform = rcsdk.getPlatform();
~~~

~~~ csharp
var platform = rcsdk.GetPlatform();
~~~

Now that you have your platform singleton and SDK has been configured with the correct server URL and API key, your application can log in so that it can access the features of the API.

## Login via 3-legged OAuth
Expand Down Expand Up @@ -378,6 +390,20 @@ platform.authorize({
});
~~~

~~~ csharp
try
{
var authResult = platform.Authorize("+18001234567", "101",
"yourpassword", true);

//your code here
}
catch (Exception ex)
{
//log or notify authorization exception
}
~~~

Client-server applications can use the 2-legged OAuth approach which doesn't provide a user login page.

To log in to RingCentral, get the Platform object and call its authorize method, providing valid username, extension, and password values. Enter your phone number in E.164 format for username. The `+` may be omitted.
Expand Down Expand Up @@ -411,6 +437,22 @@ platform.isAuthorized()
if (platform.isTokenValid()) {...}
~~~

~~~ csharp
// To check authentication status:
if (platform.IsAuthorized()){

//your code here

}else{

//go through the authorization process again

}

// C# SDK doesn't provide a way to check auth status synchronously
// without auto-refresh of the access token yet
~~~

The `isAuthorized` method will automatically perform a refresh of the access token, if needed. This method may be used in the login page of your application for automatic login.

There is also a synchronous method for checking the authentication status that does not automatically perform a refresh of the access token.
Expand All @@ -422,6 +464,10 @@ There is also a synchronous method for checking the authentication status that d
platform.refresh().then(...)
~~~

~~~ csharp
platform.Refresh();
~~~

Access token refresh normally happens automatically for common use cases. On rare occasions, you may perform a refresh of the access token manually by calling the refresh method using the `platform.refresh()` method.

## Logout
Expand All @@ -433,6 +479,10 @@ platform.logout()
platform.logout().then(...)
~~~

~~~ csharp
platform.Logout();
~~~

Your application can log out the user by calling the `platform.logout()` method.

# Making Calls (RingOut)
Expand Down