Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Need implementation pattern for REST token header fetch and set
Forum Updated to NodeBB v4.3 + New Features

Need implementation pattern for REST token header fetch and set

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 172 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JohnGa
    wrote on last edited by
    #1

    Hello,
    From within my Qt client I need to make REST calls. The first call is to authenticate and get a token from the server. After that, for all subsequent calls, the token will be set in the header as a bearer token.

    Since all the calls via QNetworkAccessManager are asynchronous, I need to chain the calls. First do the authentication. If and when that is successful, then execute the next call.

    This is more a Qt asynchronous coding question. How can I chain multiple asynchronous calls? Executed the first QNetworkAccessManager call, after successfully processing the slot for the first call, then I need to make the second QNetworkAccessManager call, process the slot for the second call.

    Can you please give me guidance on how to implement this.

    Thanks.

    JonBJ 1 Reply Last reply
    0
    • J JohnGa

      Hello,
      From within my Qt client I need to make REST calls. The first call is to authenticate and get a token from the server. After that, for all subsequent calls, the token will be set in the header as a bearer token.

      Since all the calls via QNetworkAccessManager are asynchronous, I need to chain the calls. First do the authentication. If and when that is successful, then execute the next call.

      This is more a Qt asynchronous coding question. How can I chain multiple asynchronous calls? Executed the first QNetworkAccessManager call, after successfully processing the slot for the first call, then I need to make the second QNetworkAccessManager call, process the slot for the second call.

      Can you please give me guidance on how to implement this.

      Thanks.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @JohnGa
      You just need to await (i.e. do nothing, let the Qt event loop run, until signal arrives) either finished or error on the network reply to your first request, then you are ready to send the second one.

      You can maintain state for where you are --- e.g. a list of calls to make or functions to call after each one or state/number --- in a single slot handler if you wish. Rather than, say, keep changing which slot function is connected for each call.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved