question

Suraj Gahatraj avatar image
Suraj Gahatraj asked ·

errorCode" : "OAU-156", "message" : "Basic authentication header is missing or malformed"

I'm having issue when I authorize my console application through C#SDK, I want to get company details using the Glip Api. I am using the username and password for authorization since it is an console application. I am getting the following error


public async Task GetUserList()
        {
            string companyId = "~";
            RestClient rc = new RestClient(
                 Environment.GetEnvironmentVariable(CredConstant.ClientId),
                 Environment.GetEnvironmentVariable(CredConstant.ClientSecret),
                 false
             );

            rc.token = await rc.Authorize(
                  Environment.GetEnvironmentVariable(CredConstant.Username),
                  Environment.GetEnvironmentVariable(CredConstant.Extension),
                  Environment.GetEnvironmentVariable(CredConstant.Password)
              );
            var r = await rc.Restapi().Glip().Companies(companyId).Get();
        }

Here's the response

RingCentral.RestException: Response:
StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Server: nginx
Date: Fri, 08 Jan 2021 21:02:04 GMT
Connection: keep-alive
X-Application-Context: application:8080
WWW-Authenticate: Basic realm="RingCentral REST API", error="invalid_request", error_description="Basic authentication header is missing or malformed"
RCRequestId: c2c75588-51f4-11eb-b382-005056bb0d1e
Pragma: no-cache
Cache-Control: no-store
AceRoutingKey: sjc11-c01-ace11.21dc095d-4b74-11eb-af02-005056bb6e9b
Content-Type: application/json; charset=utf-8
Content-Length: 235
Content-Language: en
}
Content: {
"error" : "invalid_request",
"errors" : [ {
"errorCode" : "OAU-156",
"message" : "Basic authentication header is missing or malformed"
} ],
"error_description" : "Basic authentication header is missing or malformed"
}

Request:
Method: POST, RequestUri: 'https://platform.devtest.ringcentral.com/restapi/oauth/token', Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers:
{
X-User-Agent: Unknown/0.0.1 RingCentral.Net/4.1.0
Authorization: Basic Og==
Request-Id: |c9b13a2b-4d773cb3d59b2507.1.
Content-Type: application/x-www-form-urlencoded
Content-Length: 19
}
Content: grant_type=password
at RingCentral.RestClient.Request(HttpRequestMessage httpRequestMessage, Int32 retriedTimes, Nullable`1 cancellationToken)
at RingCentral.RestClient.Request(HttpMethod httpMethod, String endpoint, Object content, Object queryParams, Nullable`1 cancellationToken)
at RingCentral.RestClient.Request[T](HttpMethod httpMethod, String endpoint, Object content, Object queryParams, Nullable`1 cancellationToken)
at RingCentral.RestClient.Post[T](String endpoint, Object content, Object queryParams, Nullable`1 cancellationToken)
at RingCentral.Paths.Restapi.Oauth.Token.Index.Post(GetTokenRequest getTokenRequest, Nullable`1 cancellationToken)
at RingCentral.RestClient.Authorize(GetTokenRequest getTokenRequest)
at RingCentralNotification.Controllers.RingCentralNotificationController.GetUserList() in D:\NotificationRC\RingCentralNotification\RingCentralNotification\Controllers\RingCentralNotificationController.cs:line 25
at lambda_method(Closure , Object )
at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

HEADERS
=======
Accept: */*
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Host: localhost:44387
User-Agent: PostmanRuntime/7.26.8
Postman-Token: e0cbf9fc-fc85-42f9-92fa-30a29d4b501b

c##api#passwordflow
1 |1000 characters needed characters left characters exceeded

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

1 Answer

· Write an Answer
Anirban avatar image
Anirban answered ·

Did you check if client id and client secret are correctly given. It should be base64 encryption of client id and client secret .

1 |1000 characters needed characters left characters exceeded

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Work together.
From anywhere.

Team messaging, video meetings
and phone - all in one app.


Get the new RingCentral app