easoncxz / twitanalysis

Dig your Twitter data
https://easoncxz.github.io/twitanalysis
Other
1 stars 0 forks source link

Investigate making OAuth 1.0a signed requests from the browser #4

Closed easoncxz closed 4 years ago

easoncxz commented 4 years ago

Browsers can't keep an OAuth 1.0a "Consumer Secret" secret, so there may be implications about whether it's a good idea (or even possible, due to concerns like CORS) to attempt to make OAuth 1.0a requests from a browser.

Find out whether to do OAuth-signing in the browser or on the server.

Related reading:

easoncxz commented 4 years ago

It's really tricky; the Twitter docs don't say what format parameters should be sent in --- application/x-www-form-urlencoded or application/json or query-string?

And on the other hand, oauth-1.0a doesn't say what format their RequestOptions?.data field should be. The .d.ts provided along with the library says:

  /**
   * Request options.
   */
  export interface RequestOptions {
    url: string;
    method: string;
    data?: any;
    includeBodyHash?: boolean;
  }

any!!

It'll be necessary to either dig through docs, or look at working libraries to figure out what's going on.

Reading list:

easoncxz commented 4 years ago

Ok here's the plan:

easoncxz commented 4 years ago

Reasonable progress so far. Commit 54e70e5f successfully sent tweets:

Related Twitter documentation:

It seems unnecessary to continue with the plan with reverse-engineering using http-echo-server, because the implementation using node-oauth is explicit enough that I feel pretty confident. There are basically two options for Twitter v1.1 API's POST endpoints:

Next time it would be reasonable to attempt to implement the same thing using fetch via some kind of fetch library.

easoncxz commented 4 years ago

Just one more step before this issue can be closed:

Edit: abandoning this check-box. I want people to be able to use my app, while not leaking my Consumer credentials. See #5 for continuation.