REST API Create Session Error [tokbox] or [opentok] - opentok

Getting an issue when trying to call opentok/session/create api.
When calling the api through code i keep getting an error saying the connection has been closed. So I decided to try through postman and the error i'm getting back is a 500 internal server error and a message
{
"message": "Internal server error, working hard to fix it, sorry",
"code": -1
}
As far as I can see I have everything set correctly.
Headers, Body ]
I don't think this is a JWT issue as according to the documentation that would be a 403. https://tokbox.com/developer/rest/#session_id_production
Anyone experienced this or a similar issue before

The issue ended up being the content Content-Type header I had to set
Content-Type: application/x-www-form-urlencoded
Credit to #adrice727's comment for suggesting there might be an issue with the Content-Type header.

Related

Why does my login endpoint in django knox throw "Bad request..." error?

I used files from "https://github.com/Omkar0231/Django-Login-API" with as is. The login request from Postman is resulting in error, "detail": "JSON parse error - Expecting value: line 1 column 1 (char 0)", while the terminal shows "Bad request...".
The developer of the source code in above git has also explained it in a video, "https://www.youtube.com/watch?v=6d0fiPj0dsA", however, in video everything seems to be working as expected.
Whatever I understood from Googling, I thought that a bearer token is to be included in the login request as header. But I don't know where to find the bearer token in my Django app. However, in the video, the original author/developer did not include any such header token for the login request from Postman.
Please help me figure out the issue.

The mandatory 'Content-Type' header is missing

I was working on asp.net web api and used OpenIdDict as a way to add authorization. I got some problems, which I quickly resolved, but got stuck on one. Whenever I call the Exchange from the controller, it returns 400 and a response body:
{
"error": "invalid_request",
"error_description": "The mandatory 'Content-Type' header is missing.",
"error_uri": "https://documentation.openiddict.com/errors/ID2081"
}
I have experimented and searched more and found out, that the 1 part causing the problem is this:
[HttpPost("~/connect/token")]
[Produces("application/json", "application/vnd.my.v1+json")]
the post runs as intended, but the 'produces' can't define the content-type for the request and that's why I get an error. Even know all this, I don't know how to resolve the error. I have even re-tested an already working project and the same error occurred.
This is what i did when i tried to test my api to authorize using postman.
In the body choose data type as
x-www-form-urlencoded
and set content type in the headers to
application/x-www-form-urlencoded

406 Not acceptable with Accept header any

I am trying to do DELETE http request to an API ( I don't have access to the source code of it) but the API keeps responding with 406.
I tried to put "Accept" header any but the issue still the same, I see the headers are correct.
Any help is appreciated

Invalid_grant error on trying to get access token googleapi

I'm following the steps here . I've got the authorization code in the browser, but get a:
** Access error: protocol error: "Server error: HTTP/1.0 400 Bad Request"
when I generate my request to try and obtain my token. I changed the target to http so that I could trace the http request in wireshark and I get this with line wrap added:
POST /oauth2/v3/token HTTP/1.0
Accept: */*
Accept-Charset: utf-8
Host: www.googleapis.com
User-Agent: REBOL
Content-Type: application/x-www-form-urlencoded
Content-Length: 251
code=url-encoded-my-authorisation-code&
client_id=my-client-id.apps.googleusercontent.com&
client_secret=my-client-secret&
redirect_uri=urn-blah-blah&
grant_type=authorization_code
which looks good to me.
When I use the http instead, I get this message
{"error":"internal_failure","error_description":"SSL is required to perform this operation."}
but unfortunately it's not telling me if my request is otherwise off to help me with the ssl request.
PS: I've progressed further. I removed the URL encoding from the redirect_uri and now I get an invalid_grant error. Before this it complained of a missing scheme for the redirect_uri.
On one occasion I did success in obtaining an access token but I've not been able to reproduce this. I saw my app listed in those I've granted access tokens. I removed my app and tried to grant again but keep failing.
My clock is correct so that's not the issue. The oauth2 playground works fine and as far as i can tell I'm doing the same but without success.
Mine is an installed app so I can't provide my credentials to the playground as a way to trust their redirect_uri is not provided and I get an error.
It seems that there is a limit on refresh_tokens and although removing the app from those with authority to access my calendar did not work, deleting my project from the https://console.developers.google.com/ and recreating them worked. My code then ran successfully without any changes.
Try change url to get info about token from Google use https://www.googleapis.com/oauth2/v3/tokeninfo?access_token={accessToken}
Be careful vith version api

Mandrill API error for send request

I have a problem while sending a message via Jersey client on Mandrill API. I use Jersey client as follows:
ClientBuilder.newClient()
.register(JacksonJsonProvider.class)
.target(“https://mandrillapp.com/api/1.0/messages/send.json”)
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.json(methodEntity));
Below you can see logged headers, method and content of the API request.
POST https://mandrillapp.com/api/1.0/messages/send.json
Accept: application/json
Content-Type: application/json
{"message":{"subject":"Hello World!","text":"Really, Im just saying hi from Mandrill!","to":[{"email":"marcel#xxxx.com","name":"Marcel cccc","type":"to"}],"headers":{},"tags":["test"],"from_email":"info#xxxxx.com","auto_text":true,"preserve_recipients":false},"async":false,"key":"EWIBVEIOVBVOIEBWIOVEB"}
In response to this request I keep receiving following message:
[{"email":"marcel#XXXX.com","status":"rejected","_id":"0ea5e40fc2f3413ba85b765acdc5f17a","reject_reason":"invalid-sender"}]
I do not know what the issue may be, from some posts I figured out I must use UTF-8 to encode my message and headers. But setting encoding to UTF-8 did not do much good. Otherwise the payload seems fine to me and moreover I found on forums that invalid sender can mean any other kind of issue (not just invalid sender which is sad).
I had exactly same problem with
"reject_reason":"invalid-sender"
You probably check already similar question Mandrill “reject_reason”: “invalid-sender”
Try it if it helps. I realize that you also missing header parameter in your request
e.g. User-Agent: Mandrill-myclient/1.0
Please try also add this parameter to your Jersey Client setup as following:
ClientBuilder.newClient()
.register(JacksonJsonProvider.class)
.target(“https://mandrillapp.com/api/1.0/messages/send.json”)
.request(MediaType.APPLICATION_JSON_TYPE)
.header("User-Agent", "Mandrill-myclient/1.0")
.post(Entity.json(methodEntity));
Does it help?

Resources