Giter VIP home page Giter VIP logo

reqclient's Issues

invalid_request, can't post parameters

I need help to get my access_token. it had been a week but still could't find out how, and decide to request help from here.
I am trying to request post to oauth.opskins but it doesn't see my parametes. How can I send required parameters to server?

var client = new RequestClient({
            baseUrl:"https://oauth.opskins.com/v1/",
            debugRequest:true, debugResponse:true,
            auth:{
                user: '**my_client_id_here**',
                pass: '**my_secret_here**'
            }
        });
    
        var resp = client.post("access_token", {"grant_type": "authorization_code", "code":`${req.query.code}`},{headers: {"authorization":"Basic **my_key-here**"}});

I am getting this output

[Response access_token]<- Status 400 - {"error":"invalid_request","error_description":"The grant_type parameter is required"}

OAuth2 login with unauthorized error with JSON response are propagated as a string message

When a connection with the OAuth fails for example given bad credentials, the connection is rejected with a promise (that's fine), but the content of the promise has an string representation of the error instead of a JSON object. For example a request like this:

[Requesting token]-> -X POST https://api.somesite.com/oauth/token -u ${CLIENT_ID}:${CLIENT_SECRET} -d 'grant_type=client_credentials'
[Response   token]<- Status 401 - {"timestamp":1478781997822,"status":401,"error":"Unauthorized","message":"Bad credentials","path":"/oauth/token"}

In the catch handler:

client.get(...)
.then(function(response) {
  // Things work ...
})
.catch(function(err) {
  console.log("type of err: " + typeof(err)); //--> This print "type of err: string"
});

Error array parameters in "query" object parsed as unique param in URIs

This request:

client.get({uri:"users", query: {"deleted":false,"status":["new","confirmed"]}})

Will generate this URI:

/users?deleted=false&status=new,confirmed

But must generate:

/users?deleted=false&status=new&status=confirmed

Also a way to overwrite this behavior without overwrite the all _parseUri(uri,options) method would be convenient.

curl response cannot be tapped

Hello,
I have following code:
var RequestClient = require("reqclient").RequestClient;
var client = new RequestClient({
baseUrl:"http://19.160.168.50:3000/api",
debugRequest:false, debugResponse:true
});
var jsData = { "$class": "org.acme.test.User",
"user_id": "u6","user_oro_id": "rag",
"firstname": "raghav","lastname": "bhatta",
"email": "[email protected]", "Phone": "123",
"address": "adasd", "address1": "asda",
"city":"ada", "state": "asd", "country": "dfd",
"user_type": "dfd"
};
let resp = client.post("User", jsData, {headers: {"Content-Type":"application/json", "Accept":"application/json"}});
But I cannot tapped response. I want to read statusCode from the response which is not happening. Can you please suggest.

Thank you

Implement L2 cache

Currently there is a L1 cache that allows recover the resource from the cache, but if the time expires, reqclient goes to the server to get a fresh value blocking the request until the response (but asynchronous, of course ;) .

The L2 cache could never expire, or have a higher TTL, and the most important, it will allow to reqclient return a value and fire the request to get a fresh value for the next call (the value obtained from the server will update both caches).

Improve the query encoding

The library should use encodeURIComponent() standard method instead of do string replacements manually.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.