Forum Discussion

KaiHoelscher's avatar
KaiHoelscher
New Contributor
9 years ago
Solved

Can I implement a custom "Authorization Type"?

 Hi Support!

 

for our REST service, none of the provided "Authorization Types"[1] can be used. We use a "special String token" in a custom HTTP header field for authorization purposes. So what we would need to do:

 

1. Perform a POST request to a dedicated authentication service that consumes a login name and a password

2. Extract the "special String token" from the authentication service's response (if the request succeeded)

3. Store this "special String token"

4. Set the corresponding HTTP header field with the "special String token" in each request (that is assigned this type of authorization

 

Can we implement some kind of interface to implement this way of authorization?

 

[1]

http://readyapi.smartbear.com/features/auth/types/start

 

Greetz,

Kai

  • There's currently no custom interface to create your own authentication methods, but one thing you could do is to set this header in an event handler of type RequestFilter.filterRequest.

     

    Read more about Events here:

    http://readyapi.smartbear.com/readyapi/events/start

     

    I suggest that you look for the token as a custom property in the Test case, and if it's not present, get it using some Groovy code and store it in the custom property. Then use the value to set the header on the request.

     

    Kind regards,

    Manne Fagerlind, Ready! API Developer

2 Replies

  • There's currently no custom interface to create your own authentication methods, but one thing you could do is to set this header in an event handler of type RequestFilter.filterRequest.

     

    Read more about Events here:

    http://readyapi.smartbear.com/readyapi/events/start

     

    I suggest that you look for the token as a custom property in the Test case, and if it's not present, get it using some Groovy code and store it in the custom property. Then use the value to set the header on the request.

     

    Kind regards,

    Manne Fagerlind, Ready! API Developer

    • KaiHoelscher's avatar
      KaiHoelscher
      New Contributor

      Hi Manne,

       

      first of all: Thanks for the quick reply!

       

      Well, I'm not sure, if the benefit outweighs the cost (in our case). But at least, this is an idea we can maybe come back to, later.

       

      (You can treat this issue as CLOSED.)

       

      Regards,

      Kai Hölscher