Question

C# SDK Cannot Authorize - Bad Request

  • 19 October 2018
  • 3 replies
  • 1381 views

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



3 replies

  **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
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?

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?

Reply