question

it-admin12325 avatar image
it-admin12325 asked Tyler Liu answered

C# SDK Cannot Authorize - Bad Request

Private App Authorization

Platform Type: Server/BOT (plan to surface MS BOT Framework in Glip)

Permissions: Glip, Read Contacts, Read Messages


I'm using the RingCentral Client C# SDK as shown on Github to authorize:

var oToken = await oRestClient.Authorize(cUserName, "", cPassword);


And I keep getting the same error: {"Call failed with status code 400 (Bad Request): POST https://developer.ringcentral.com also I can log into my RingCentral.com account with my credentials so why is authentication failing?


StackTtrace:

Message: Call failed with status code 400 (Bad Request): POST https://platform.devtest.ringcentral.com/restapi/oauth/token

StackTrace: at Flurl.Http.FlurlRequest.<HandleExceptionAsync>d__23.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)

at Flurl.Http.FlurlRequest.<SendAsync>d__19.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at Flurl.Http.FlurlRequest.<SendAsync>d__19.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Flurl.Http.HttpResponseMessageExtensions.<ReceiveJson>d__0'1.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at RingCentral.RestClient.<Authorize>d__39.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult()

at RESTAPI_Testing.Program.<Main>d__0.MoveNext() in ...Program.cs:line 53


sdk
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
  **Q: Why does OAuth return "unauthorized for this grant type" error?**

  **A:** The error "unauthorized for grant type" occurs when your application is attempting to use an OAuth grant type that it is not approved to use. This often happens when your app requires the Authorization Code Flow but is attempting to use the Password Flow. See below for information in implementing Authorization Code Flow. For more information see [this Developer Community article]( https://devcommunity.ringcentral.com/ringcentraldev/topics/unauthorized-for-this-grant-type-error).


  **Q: How to deal with "Unauthorized for this grant type" issue?**
  
  **A:** It probably means your app doesn't support password authorization flow. Please logon https://developer.ringcentral.com and confirm that your app has the following configuration: https://cloud.githubusercontent.com/assets/733544/18026560/b93e5356-6c7d-11e6-92a9-d35d28325e69.png
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

it-admin12325 avatar image
it-admin12325 answered Phong Vu commented
If my users are already authenticated via Glip/Ring Central App. Why can I not access posts and groups via the admin username password.  At this point I do not have an additional server component for authentication. 

1) Can this not be handled by the C# SDK? 

Also, documentation states
Please note: Glip App (mobile or desktop) does NOT have:

  • support for the RingCentral Sandbox API (cannot switch to 'developer mode');

  • does not have a 'Sandbox version'

2) Does this mean I cannot talk to the API from sandbox app?

3) Also if I do not have an authentication/authorization server other that Glip right now do I even need an OAuth Redirect URI?

3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image Tyler Liu ♦ commented ·
You cannot access other users's Glip posts/groups even you are admin. It is by design.

You can try other SDK if you don't like the C# one. We have SDKs for popular languages.

You CAN talk to Glip API from sandbox APP. But your sandbox app can only access sandbox env. (production and sandbox are separated env)

You can leave oauth redirect uri field empty and fill it later.
0 Likes 0 ·
it-admin12325 avatar image it-admin12325 commented ·
Please note: I do not have an issue with the C# API. For the  Platform Type I am building, RingCentral locks me into the Authorization Code "Authorization Flow type" for the Bot App I am using so:
1) Should I create a new app as other or Server-only (No-UI)?
2) More importantly can I add the Glip permission to my app
3) Will I still be able to integrate it into Glip?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·
Hi IT Admin,

To test your Glip app on sandbox, use this link instead of the App.  https://glip-app.devtest.ringcentral.com/

Hope this helps,
+ Phong
0 Likes 0 ·
Tyler Liu avatar image
Tyler Liu answered
1) Should I create a new app as other or Server-only (No-UI)? 

Generally you should stick to Server/bot app type if you are building a bot. This is because, we provide never expire tokens for bot apps. So you can forget about bot token refresh.


2) More importantly can I add the Glip permission to my app

Yes, when you create the app, you can specify Glip permission (no matter what app type you choose). Can't you? Let me know if you have difficulty on this


3) Will I still be able to integrate it into Glip?

Yes I think so but as I said I think you should stick to Server/bot app type.



Why do you dislike Authorization Code "Authorization Flow type" ? Is there anything prevent you from using it?

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys