News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
errorCode" : "OAU-156", "message" : "Basic authentication header is missing or malformed"
Tags: rest api
Jan 8, 2021 at 1:18pm   •   1 replies  •  0 likes
Suraj Gahatraj

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

1 Answer
answered on Jan 9, 2021 at 6:56am  

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


 0



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

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us