using RingCentralSDK
I am not able to get token.
when ever i try to authorize it gives error "Unauthorized for this grant type"
here is my code
Unauthorized for this grant type
using RingCentral;
using RingCentral.Http;
using System.Net.Http;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
/// <summary>
/// Summary description for Bulk_sms
/// </summary>
public class Bulk_sms
{
public string authid = "PZurrww4RtyPR1it0KyI9w", authtoken = "sJoF2hukSg637r-f3p2JwAbYUFC1ohQuO13obpG4MBYg", account = "+13133956838", password = "sagar@123";
public ApiResponse send_bulk(string src, string dest, string text)
{
try
{
src = "+" + src;
dest = "+" + dest;
var sdk2 = new SDK(authid, authtoken, SDK.Server.Sandbox, "SMS", "1");
sdk2.Platform.Login(account, "101", password, true);
//var body = text;
//var from = src;
//var to = dest;
//var jsonData = "{\"to\": [{\"phoneNumber\": \"" + to + "\"}]," +
// "\"from\": {\"phoneNumber\": \"" + from + "\"}," +
// "\"text\": \"" + text + "\" }";
//string SmsEndPoint = "/restapi/v1.0/account/~/extension/~/sms";
//Request request = new Request(SmsEndPoint, jsonData);
//ApiResponse response = sdk2.Platform.Post(request);
//return response;
var requestBody = new
{
text = text,
from = new { phoneNumber = src },
to = new object[] { new { phoneNumber = dest } }
};
var jsonString = JsonConvert.SerializeObject(requestBody);
var request = new Request("/restapi/v1.0/account/~/extension/~/sms", jsonString);
ApiResponse response = sdk2.Platform.Post(request);
return response;
}
catch (Exception)
{
throw;
}
}
Please Help Me...????????
With the Browser-Base platform type, you have to implement the 3-legged authentication. See this demo for some code and understanding the flow. https://github.com/ringcentral/ringcentral-demos-oauth
Otherwise, you have to change the platform type to Server/Web and access RingCentral APIs from the your server code.
Unfortunately, you cannot change the platform type after your app is created. Either you create a new app and select the correct type. Or let me know your app name so I can help change it.
+ Phong
I am developing this application in ASP.Net WebForm
Please guide me
Thanks
i am developing a web-app/ website in asp.net C#
i have tried the ringcentral-csharp-client
i do not get the token it just keeps on waiting to get token response.
it just do not go beyond await.
in testing api it tried to send a message using phone number and it was delivered.
here is my code
using System;
using RingCentral;
private static async System.Threading.Tasks.Task<string> GetAuthorized()
{
RestClient rc = null;
string appKey = "PZuit0KyI9w";
string appSecret = "sJoF2hukSg637r-f3p2JwAbYUFC1ohQuO13obpG4MBYg";
string phoneNumber = "";
string password = "";
rc = new RestClient(appKey, appSecret);
await rc.Authorize(phoneNumber, "101",password);
var tokenString = rc.token.access_token;
var extension = rc.Restapi().Account().Extension();
var requestBody = new
{
text = "hello -- Vidhyut",
from = new { phoneNumber = phoneNumber },
to = new object[] { new { phoneNumber = "+15162190172" } }
};
var response = await extension.Sms().Post(requestBody);
return tokenString;
}
please help me.
Please search this community for "Unauthorized for this grant type". This question has been answered. It is not a coding issue but an account issue. Phone is correct that you should use https://github.com/ringcentral/ringcentral-csharp-client
You code is not really readable. I guess you are trying to use the RingCentral C# SDK right? Please use this SDK https://github.com/ringcentral/ringcentral-csharp-client and read the instructions and see sample code on the README page to setup and use the SDK correctly.
You need to create and initialize a client instance
using RingCentral;
rc = new RestClient("appKey", "appSecret");
Then call the authorize function to get the accessToken
await rc.Authorize("username", "extension", "password");Goto the Send SMS section to see how to post a SMS request.
Read this for more information about SMS
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefSMSMessages.html
Hope this helps,
+ Phong
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder