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
auth code flow - OAuth2::Error: invalid_client: Client authentication is required
Tags: authentication, sdk, oauth2, auth
Apr 26, 2022 at 11:03am   •   2 replies  •  0 likes
R N

Hi, I am using the standard ruby ringcentral sdk Here is how I am trying to authenticate a user using the auth code flow.

Step 1

       @client ||= RingCentralSdk::REST::Client.new do |config|
         config.server_url = RingCentralSdk::RC_SERVER_SANDBOX
         config.app_key = "client_id"
         config.app_secret = "client_secret"
         config.redirect_url= "redirect_url"
       end

Step 2 I provide my consent using a browser with url @client.authorize_url

Step 3. I copy the code returned by the api and try to exchange it with a token like so

  token = @client.authorize_code(code)

No matter what I do, I always get this error

 {
   "error" : "invalid_client",
   "errors" : [ {
     "errorCode" : "OAU-123",
     "message" : "Client authentication is required"
   } ],
   "error_description" : "Client authentication is required"
 }

Here are my Ringcentral app settings

App Type: - REST API App (most common)

Auth: - 3-legged OAuth flow authorization code, - Server-side web app

App permissions: - VoIP Calling

Who will be authorized to access your app? - This app is public and will be callable via any RingCentral customer.

What brand partners are available? - Make available to all current and future RingCentral carrier and brand partners(recommended)

I have even done several combinations of these settings to no luck

2 Answers
answered on Apr 27, 2022 at 7:12am  

You said that you are using the RingCentral Ruby SDK, but you did not show how you call the SDK authorize method.

What is inside this method? It is not part of the SDK methods.

 token = @client.authorize_code(code)

Anyway, here is an example how to authenticate a user using 3-legged authorization using the RingCentral Ruby SDK.


 0
answered on Apr 26, 2022 at 10:35pm  

Thanks Byrne for the answer However here I am using the Ringcentral SDK for authorization and exchanging the code with token. Given that it is the official library of RingCentral, I assume it should add the proper headers. I confirmed that it does by digging into the code. Here is an excerpt from the GitHub repo

 def autorization_header
   @token != nil ? "Bearer #{@token['access_token']}" : "Basic #{basic_key}"
 end

 0
answered on Apr 26, 2022 at 11:13am  

I believe you are seeing this error message because when you exchange the auth code for an access token you need to present an HTTP Authorization header that base64 encodes your client id and secret. See here:

https://developers.ringcentral.com/guide/authentication/auth-code-flow#step-3-exchange-auth-code-for-access-token

Please let me know if this successfully resolves the problem you are seeing!


 0
on Apr 26, 2022 at 10:35pm   •  0 likes

Thanks Byrne for the answer However here I am using the Ringcentral SDK for authorization and exchanging the code with token. Given that it is the official library of RingCentral, I assume it should add the proper headers. I confirmed that it does by digging into the code. Here is an excerpt from the GitHub repo

 def autorization_header
   @token != nil ? "Bearer #{@token['access_token']}" : "Basic #{basic_key}"
 end
on Apr 26, 2022 at 1:58pm   •  0 likes

Here are some other resources that may also be at the root cause of your issue: * https://community.ringcentral.com/questions/8334/password-flow-errorcode-oau-123-client-authenticat.html



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