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
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.
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
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:
Please let me know if this successfully resolves the problem you are seeing!
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
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