Git Product home page Git Product logo

contextio-node's People

Contributors

abstractmatter avatar arwid avatar bigdadbear avatar cecyc avatar gavinuhma avatar michaelbernstein avatar pdobrev avatar slava-tre avatar souvik1997 avatar stefek99 avatar sushithegreat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

contextio-node's Issues

400 on new_folder_id PUT

ctxioClient
  .users(userID)
  .email_accounts(inboxLabel)
  .folders('INBOX')
  .messages(messageID)
  .put({
    new_folder_id: folder,
  }).then(res => {
    console.log(res);
  });

is throwing the below error even though the value is there:

Unhandled rejection StatusCodeError: 400 - "{\"type\":\"error\",\"value\":\"new_folder_id is required\"}"
    at new StatusCodeError (/var/www/alexbeals.com/public_html/projects/victor/node_modules/contextio/node_modules/request-promise/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/var/www/alexbeals.com/public_html/projects/victor/node_modules/contextio/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/var/www/alexbeals.com/public_html/projects/victor/node_modules/contextio/node_modules/request-promise/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/var/www/alexbeals.com/public_html/projects/victor/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/var/www/alexbeals.com/public_html/projects/victor/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/var/www/alexbeals.com/public_html/projects/victor/node_modules/request/request.js:1091:12)
    at IncomingMessage.g (events.js:286:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Including the dictionary as the second parameter causes the same error as #35.

Does not support POST /messages/<messageID>/folders with type array value for "add" or "remove" keys

There is an inconsistency with how the OAuth.js file and querystring package format URLs, causing a signature error on the baseURL.

Querystring natively separates out the array into duplicate key/value pairs, eg: &add=Today&add=Tomorrow

OAuth.js has a bug which strips any values beside the first in the array, eg: &add=Today

Context.IO API requires each element in the array to be broken out into a separate key/value pair, with square brackets before the equal sign, eg: &add[]=Today&add[]=Tomorrow

I'll submit a PR for the fix to OAuth.js and to Querystring, but I'm not sure querystring's implementation of array stringification is incorrect, so they might decide to not support the bracketing convention.

Thoughts? It seems both redundant and inefficient to have URL formatting functions in OAuth.js and to use the querystring package to achieve the same job, especially since the server is comparing the URL with its signed counterpart.

GET connect_token - returning entire list?

Hi,

Has anyone experienced this before, I running the get required after a user has created an account, to retrieve the information on the token and get account information to associate with user.
I run the query and it returns the entire list of connect_tokens, with the last one being the most recent and token I am looking for.

Here is my current function, where id is equal to the id of the token I am looking for

return ctxioClient.connect_tokens().get({ token: id }).then( function (res) {
      return res
    } ).catch( function (err) {
      console.log('err', err.message)
    });

screen shot 2017-02-01 at 7 12 16 pm

This image is the end of the response I am receiving, and the rest is a long list of past tokens

401 on PUT message

Hello, I receive error on Message API CALL :

var ctxioClient = ContextIO({
    key: config.contextio.key,
    secret: config.contextio.secret,
    version: config.contextio.version
  });
  //PUT https://api.context.io/lite/users/ID/email_accounts/LABEL/folders/FOLDER/messages
  ctxioClient.users(config.contextio.userId)
    .email_accounts(config.contextio.label)
    .folders(config.contextio.inboxFolder)
    .messages(message.message_id)
    .put({ new_folder_id: ANOTHERFOLDER })
    .then(function (ctxioClientRes) {
      res.json(ctxioClientRes);
    });

/*
 * The error Stack :
Unhandled rejection StatusCodeError: 401 - {"type":"error","code":105,"value":"Invalid signature \/f9Qf7YEq44qY8CVmpLKtDperlM=. Signature base string should be PUT&https%3A%2F%2Fapi.context.io%2Flite%2Fusers%USERID%2Femail_accounts%2Fcontenu%2540EMAIL%253A%253ASMTP%2Ffolders%2FINBOX%2Fmessages%2F%MESSAGEID%2540%253E%2F&oauth_consumer_key%%26oauth_nonce%%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%%26oauth_version%3D1.0"}
    at new StatusCodeError (/home/charles/dev/komunity-app-web/node_modules/request-promise/lib/errors.js:26:15)
    at Request.RP$callback [as _callback] (/home/charles/dev/komunity-app-web/node_modules/request-promise/lib/rp.js:68:32)
    at Request.self.callback (/home/charles/dev/komunity-app-web/node_modules/request-promise/node_modules/request/request.js:186:22)
    at emitTwo (events.js:100:13)
    at Request.emit (events.js:185:7)
    at Request.<anonymous> (/home/charles/dev/komunity-app-web/node_modules/request-promise/node_modules/request/request.js:1081:10)
    at emitOne (events.js:90:13)
    at Request.emit (events.js:182:7)
    at IncomingMessage.<anonymous> (/home/charles/dev/komunity-app-web/node_modules/request-promise/node_modules/request/request.js:1001:12)
    at IncomingMessage.g (events.js:273:16)
    at emitNone (events.js:85:20)
    at IncomingMessage.emit (events.js:179:7)
    at endReadableNT (_stream_readable.js:913:12)
    at _combinedTickCallback (node.js:383:13)
*/

Parse error for Attachment download API call

Hi,
I'm getting error on attachments download API call using node module 'contextio'
For the testing purpose I changed in node_modules/contextio/lib/call-service.js file where there is a JSON.parse is happening.
For downloading/getting binary data by attachements api call through node module is not able to parse and it is not need to parse the data.
API call:
ctxioClient.users(input.id).email_accounts(input.label).folders(input.folder).messages(input.message_id).attachments().get({}).
Here is the stacktrace:
SyntaxError: Unexpected token % in JSON at position 0
at JSON.parse ()
at sendRequest.then.body (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/contextio/lib/call-service.js:57:21)
at tryCatcher (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/bluebird/js/release/async.js:17:14)

Gmail oAuth: Cannot bypass intermediate steps.

While creating connect_token and obtaining oAuth2 token for Gmail, contextIO has these two intermediate steps where it asks to:

  • enter first_name last_name and email
  • sure we are signed in.

I'm able to skip the second step by making a post request to https://api.context.io/connect/<TOKEN_ID> with next=oauth and following the redirect url which takes to Google Authorization page, but NOT the first one.

My application uses Gmail only oAuth and I need to skip both of the above steps which are redundant when my end user knows he/she's connecting his Gmail with my application.

ENOTFOUND error

On all requests I do with this client, I get the following error:

{ [Error: getaddrinfo ENOTFOUND] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }

Any clue what might be causing this?

Corrupted file getting attachments

Hello,

When i try to get attachment file, the resulted file is corrupted:

exports.getAttachment = function (req, res, next) {
  var ctxioClient = ContextIO({
    key: config.contextio.key,
    secret: config.contextio.secret,
    version: config.contextio.version
  });

  ctxioClient.users(config.contextio.userId)
    .email_accounts(config.contextio.label)
    .folders(config.contextio.doneFolder)
    .messages(req.params.messageId)
    .attachments(req.params.attachmentId)
    .getFile()
    .then(function (ctxioClientRes) {
      res.set(ctxioClientRes.headers);
      res.send(ctxioClientRes.body);
    })
    .catch(function (err) {
      res.status(401).send(err);
    });
};

Any idea?

copying non-own-property issue

Hy there,

Are you Okay to switch from:

for (var i in tmp) {
tmp[i].copy(buf, length);
length += tmp[i].length;
}

To:

for (var i in tmp) {
if (tmp.hasOwnProperty(i)) {
tmp[i].copy(buf, length);
length += tmp[i].length;
}
}

To avoid errors when objects/functions are extended?

Thanks,

François

Cannot read property 'slice' of undefined at at sendRequest.then.res (node_modules/contextio/lib/call-service.js:71:74

Hi,
I'm not able call the getFile call to download the attachments.
This is the stacktrace from node module
Cannot read property 'slice' of undefined
at sendRequest.then.res (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/contextio/lib/call-service.js:71:74)
From previous event:
at Request.RP$exposed [as then] (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/request-promise-core/lib/plumbing.js:145:61)
at Object.getFile (/home/veeresh/FlowRepo/newflow/backend/backend-services/engine/node_modules/contextio/lib/call-service.js:70:40)

FYI,
I go through the call-service.js file in line number 70 there is a method called slice on the headers object content-disposition, this field have no values that's why the code was broken.
here is the line: const filename = res.headers['content-disposition'].split('=')[1].slice(1, -1);

As per your guidance I'm trying to use getFile method but this is also throwing an error, you guys are not handling errors and there is not at all try-catch block and there is no proper testing on the module and no proper documentation for the API how to use? what to pass in request , etc.
Here is the link for my last issue and it was closed without solving the issue.
#46

My code for reference:

 const ctxioClient = ContextIO({
    key: input.connection.consumer_key,
    secret: input.connection.consumer_secret
  })
//I tried both methods: get and getFile both are not working, end up with library issues.
 ctxioClient.users(input.id).email_accounts(input.label).folders(input.folder).messages(input.message_id).attachments(input.attachment_id).getFile().then(res => {
     console.log(res);
  }).catch(err => {
    console.log(err)
  })

requesting raw message results in json decoding error

It seems that the library is trying to json decode a raw email message:

const ctxioClient = ContextIO({key: '...', secret: '...', version: 'lite'})
ctxioClient
  .users('...')
  .email_accounts('...')
  .folders('...')
  .messages('...')
  .raw()
  .get()
  .then(console.log)
Unhandled rejection SyntaxError: Unexpected token D in JSON at position 0
    at JSON.parse (<anonymous>)
    at sendRequest.then.body (/Users/tpetry/Documents/contextio/test005/node_modules/contextio/lib/call-service.js:57:21)
    at tryCatcher (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/Users/tpetry/Documents/contextio/test005/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5)

Streams for file downloads

Do you plan to add support for Streams in files/:file_id/content endpoint? I am using GridFS for storing files on my side, and it would be more convenient to have a ReadStream in client.accounts(:account_id).files(:file_id).content().

Unexpected end of input

Debug: internal, implementation, error 
    SyntaxError: Uncaught error: Unexpected end of input
    at Object.parse (native)
    at IncomingMessage.<anonymous> (/.../node_modules/contextio/lib/ContextIO.js:186:26)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickDomainCallback (node.js:492:13)

400 - "{\"type\":\"error\",\"value\":\"new_folder_id is required\"}"

Hi,
I'm trying to move message from one folder to another folder, in developer API console it is working properly but using node module it's not working even though the passing of all required parameters.
I'm running lite version which is default version.
Find the below code, I'm passing new_folder_id but still node_module throwing 'new_folder_id' is required and you can see the consoles over there.

var ContextIO = require('contextio');
    const ctxioClient = ContextIO({
      key: input.connection.consumer_key,
      secret: input.connection.consumer_secret
    })
    var params = {
      "new_folder_id": input.folder_id
    };
    console.log(params); // { new_folder_id: 'NEW_1' }
    ctxioClient.users(input.id).email_accounts(input.label).folders(input.folder).messages(input.message_id).put(params).then(res => {
      return output(null, res);
    }).catch(err => {
    console.log(err)
    })

Creating account for hosted exchange 2010 fails to parse response

Debug: internal, implementation, error 
    SyntaxError: Uncaught error: Unexpected token I
    at Object.parse (native)
    at IncomingMessage.<anonymous> (.../node_modules/contextio/lib/ContextIO.js:188:26)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at instrumented (.../node_modules/opbeat/lib/instrumentation/async-hooks.js:19:23)
   at doNTCallback2 (node.js:441:9)
   at process._tickDomainCallback [as _tickCallback] (node.js:396:17)

As far as we can tell this only happens on a specific hosted exchange 2010 account but since we do not have the credentials we cannot test this. Should I also send a mail to support?

Method messages() doesn't exist in sources

I get no such method messages() when trying to run:

ctxioClient.accounts(accountId).sources(label).folders(folder).messages().get(req.query, function (err, response) {
  if (err) throw err;
  return res.json(response.body);
});

This is for the endpoint:
https://api.context.io/2.0/accounts/id/sources/label/folders/folder/messages

Looking at ContextIO.js under the sources() -> folders() function, I see methods for get, post, delete, and expunge, but no messages method.

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.