Getting unauthorized response for REST API calls via Connect app

I am trying to build a connect app with read, write and ACT_AS_USER scopes. I am able to install the app successfully and able to save the shared secret, client id and base URL in my database. But after that when I make REST API calls to get user details or issues with API endpoints such as /myself or /issues I am getting 401 unauthorized.

For eg. I am hitting /rest/api/latest/issues and getting 401 response. I am using atlassian-jwt-ruby library to create the JWT tokens.

This is the code snippet used to generate the token and make the call.

    claim = Atlassian::Jwt.build_claims(
    jwt = JWT.encode(claim, shared_secret)
    res = Typhoeus.get(url + "?jwt=#{jwt}")