TokenInvalid: OAU-213 (Token not found)

  • 1
  • Question
  • Updated 2 months ago
I have an application that downloads recordings using the ruby sdk. I am unable to download any recordings and get an error: OAU-213 (Token not found). The token should be valid since it has not expired. 

Can anyone provide any insight why this might be happening?
Photo of Allan Farinas

Allan Farinas

  • 80 Points 75 badge 2x thumb

Posted 3 months ago

  • 1
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,142 Points 5k badge 2x thumb
Could you please post your code here? (remove credentials before posting)
Photo of Allan Farinas

Allan Farinas

  • 80 Points 75 badge 2x thumb
I am using the password flow to authenticate. Here's the code:
# export RC_SERVER_URL=https://platform.devtest.ringcentral.com
# export RC_USER_USERNAME=
# export RC_USER_EXTENSION=
# export RC_USER_PASSWORD=

@client = RingCentralSdk::REST::Client.new do |config|
  config.load_env = true
end

response_file = @client.http.get do |req|
  req.url recording_url
end

response_file.status returns a 401. Here is the response I'm getting back:
{
  "errorCode" : "TokenInvalid",
  "message" : "Token not found",
  "errors" : [ {
    "errorCode" : "OAU-213",
    "message" : "Token not found"
  } ]
}
(Edited)
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,142 Points 5k badge 2x thumb
You are not taking advantage of the official RingCentral Ruby SDK. Please check it here: https://github.com/ringcentral/ringcentral-ruby
Photo of VB

VB, Official Rep

  • 1,470 Points 1k badge 2x thumb
This issue happens for a couple of reasons: 
1. Access token might be expired or another access token would be generated before the current token is expired
2.  when the credentials of the user might have changed while the access token would have been still valid
3. The token would have been corrupted 

A quick fix for this issue would be to write a business logic : 
1. Donot allow to make any API calls when this error is hit 
2. Try to refresh the access token so you generate the new pair of the access token and refresh token
3. If the refresh token is not valid/ corrupt, allow the user to authorize once again. 

If the above solution doesn't help, Feel free to drop us an email @ devsupport@ringcentral.com  with full HTTP request and response along with the response headers and with the appID and detailed description of the problem if this issue still persists. My team will get back to you with the right reason, so you can fix your app.