Id = 8, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"

  • 1
  • Problem
  • Updated 12 months ago
When i try to get access token getting this issue.

I'm using below code:

RestClient rc = null;
            if (!string.IsNullOrWhiteSpace(Config.Instance.server))
            {
                rc = new RestClient(Config.Instance.appKey, Config.Instance.appSecret, Config.Instance.server);
            }
            else
            {
                rc = new RestClient(Config.Instance.appKey, Config.Instance.appSecret, Config.Instance.production.Value);
            }
            await rc.Authorize(Config.Instance.username, Config.Instance.extension, Config.Instance.password);

            Assert.NotNull(rc.token.access_token);
Photo of sprout system2

sprout system2

  • 80 Points 75 badge 2x thumb

Posted 12 months ago

  • 1
Photo of Tyler Long

Tyler Long, Official Rep

  • 6,374 Points 5k badge 2x thumb
I think the Assert library doesn't support async await code although I am don't know which unit testing library you are using. Please change to  var token = rc.Authorize(Config.Instance.username, Config.Instance.extension, Config.Instance.password).Result;   and try again.
Photo of Sprout System

Sprout System

  • 70 Points
Thank for your response, i am also use this way, but not get the token throw the 400 Bad Request error, i pasted my code changes 

public RestClientFixture()
        {
            if (!string.IsNullOrWhiteSpace(Config.Instance.server))
            {
                rc = new RestClient(Config.Instance.appKey, Config.Instance.appSecret, false);
            }
            else
            {
                rc = new RestClient(Config.Instance.appKey, Config.Instance.appSecret, false);
            }

            var temp = rc.Authorize(Config.Instance.username, Config.Instance.extension, Config.Instance.password).Result;
        }

i refer this link to implement this concept , https://github.com/grokify/ringcentral-demos-oauth/tree/master/csharp-nancy/

but still i am not getting, 

Authorize method return below error, 
{"Request to https://platform.devtest.ringcentral.com/restapi/oauth/token failed with status code 400 (Bad Request)."}

even i download multiple source code to implement this concept using c# but all are return same issue. i don't know where i missing. Please give idea to resolve this issue.
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,190 Points 5k badge 2x thumb
Could you please run your code in Visual Studio in debug mode and inspect the inner exceptions? 400 (Bad request) is not very useful for troubleshooting.

Even when the response status code is 400, you can still get the HTTP message body and read the error detail so we could know what happened.

It might because your credentials are wrong. But we are not sure until you see the HTTP response body which contains error message.
(Edited)
Photo of Sprout System

Sprout System

  • 70 Points
Here i pasted the screenshot for the response error.

Photo of sprout system2

sprout system2

  • 80 Points 75 badge 2x thumb
hello if any idea about this issue Please let me know


(Edited)
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,996 Points 5k badge 2x thumb
We need to extract the response body. I forgot to post you more information:
https://github.com/tmenier/Flurl/issues/114
http://tmenier.github.io/Flurl/error-handling/
catch (FlurlHttpException ex) {
    // For error responses that take a known shape
    TError e = ex.GetResponseJson<TError>();

    // For error responses that take an unknown shape
    dynamic d = ex.GetResponseJson();
    string s = ex.GetResponseString();&nbsp;
}
(Edited)