swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

Qt5 C++ - JSON token authorization problem (request.setRawHeader in SWGHttpRequest)

Open Kajzer133 opened this issue 9 years ago • 1 comments

  • Version of Swagger: 2.2.2

Issue

Problem with json token authorization. I use CakePHP REST Api in project. The are a lot of tables in our MSSQL database. I want to set header for each by return token from SWGAuthenticateApi and pass it in main class, before calling, by variable for example: to object, which method inserts new data to table. Currently I use request.setRawHeader("Authorization", "here I wrote a token statically") in SWGHttpRequest.cpp. I want token to be valid only for 2h so I can't write it manually in my application. I know that i can use:

HttpRequestWorker *worker = new HttpRequestWorker(); HttpRequestInput input(fullPath, "POST"); input.headers.insert("Authorization","");

But the problem is that i can't or i don't know how to return token to my main class and add configuration. All functions are void, and there is no configuration method too. Is there an option to generate a code in Qt without void functions but with functions that return something? Or maybe there is a way to do it on voids?

In C# Client it looks like:

IrisCodeResponse result = loginApiInstance.ApiLoginPost(login); token = result.Data.Token; token = String.Format("bearer {0}", token); apiInstance.Configuration.AddDefaultHeader("authorization", token);

I want to make it similar to this, in QT.

Kajzer133 avatar Mar 10 '17 10:03 Kajzer133

This has nothing to do with the editor. Might be with the codegen, if so, open the ticket there.

webron avatar Mar 10 '17 16:03 webron