Comments (9)
i tested, follow the below steps:
init
var request = require('request');
var OAuth = require('oauth-1.0a');
var oauth = new OAuth({
consumer: {
public: 'xxx',
secret: 'xxx'
}
});
Obtaining Temporary Credentials - request token
var request_data = {
url: 'https://openapi.etsy.com/v2/oauth/request_token?scope=email_r',
method: 'POST'
};
request({
url: request_data.url,
method: request_data.method,
form: oauth.authorize(request_data),
json: true //parse respone as json
}, function(err, res, data) {
// {
// login_url: 'https://www.etsy.com/oauth/signin?oauth_consumer_key=xxx&oauth_token=xxx&service=v2_prod',
// oauth_token: 'xxx',
// service: 'xxx',
// oauth_token_secret: 'xxx',
// oauth_callback_confirmed: 'true',
// oauth_consumer_key: 'xxx',
// oauth_callback: 'oob'
// }
}
access the login_url to get the credential (oauth_verifier)
var request_data = {
url: 'https://openapi.etsy.com/v2/oauth/access_token',
method: 'POST',
data: {
oauth_verifier: 'xxx'
}
};
var token = {
public: 'xxx',
secret: 'xxx'
}
request({
url: request_data.url,
method: request_data.method,
form: oauth.authorize(request_data, token)
}, function(err, res, data) {
// oauth_token=xxx&oauth_token_secret=xxx
});
access the login_url to get the credential
Obtaining Token Credentials - access token
var request_data = {
url: 'https://openapi.etsy.com/v2/oauth/access_token',
method: 'POST',
data: {
oauth_verifier: 'xxx'
}
};
var token = {
public: 'xxx',
secret: 'xxx'
}
request({
url: request_data.url,
method: request_data.method,
form: oauth.authorize(request_data, token)
}, function(err, res, data) {
// oauth_token=xxx&oauth_token_secret=xxx
});
Making an Authorized Request to the API - since you got the tokens you can use oauth-request to play around with the API
var request_data = {
url: 'https://openapi.etsy.com/v2/users/__SELF__',
method: 'GET'
};
var token = {
public: 'xxx',
secret: 'xxx'
}
request({
url: request_data.url,
qs: oauth.authorize(request_data, token),
json: true
}, function(err, res, data) {
// {
// count: 1,
// results: [{
// user_id: 53899516,
// login_name: 'ddooo',
// primary_email: '[email protected]',
// creation_tsz: 1411796074,
// referred_by_user_id: null,
// feedback_info: [Object],
// awaiting_feedback_count: 0
// }],
// params: {
// user_id: '__SELF__'
// },
// type: 'User',
// pagination: {}
// }
});
from oauth-1.0a.
Sorry, I am not able to get this to work with Jquery Client side Javascript.
I get Access-Control-Origin header issues.
Here is what I have translated to client side Jquery code so far.
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script>
<script src="oauth.js"></script>
<script>
/*
var request = require('request');
var OAuth = require('oauth-1.0a');
*/
var oauth = new OAuth({
consumer: {
public: 'xxx-keystring',
secret: 'xxx-shared-secret'
}
});
var request_data = {
url: 'https://openapi.etsy.com/v2/oauth/request_token?scope=email_r',
method: 'POST'
};
$.ajax({
url: request_data.url,
type: request_data.method,
form: oauth.authorize(request_data),
json: true //parse respone as json
}).done(function(err, response, data) {
console.log(done);
});
</script>
from oauth-1.0a.
you can't do it on website, unless your client side is an extension or something else that allows cross domain requests
https://github.com/ddo/oauth-1.0a#client-side-usage-caution
from oauth-1.0a.
Makes total sense. I feel like an idiot. So I guess the only alternative is to create some sort of asp.net service or something to proxy the requests right?
from oauth-1.0a.
Only modern browsers disallow the cross domain requests, all the oauth request should be called on your server side, the client side just communicate with your server.
in your case:
etsy
<--> your server
<--> website
If your client side is not a website, you can send the cross domain i believe.
But you should do same as above since we can protect our secret key.
from oauth-1.0a.
Great. Let me look into this a bit. If i get a good proxy solution (php, asp) I will post my findings here.
Thank you so much in advance.
from oauth-1.0a.
So I disabled Cross Domain limitation in chrome, and now it seems like i can connect to etsy api just fine. (I know this is not good practice but for our needs its fine).
When I run the code above, etsy returns error 400.
from oauth-1.0a.
looks like they require SSL when trying to do this on the client. Going to try and do it via NginX reverse proxy and see if that gets us anywhere.
from oauth-1.0a.
sure :)
https://openapi.etsy.com/v2/oauth/
from oauth-1.0a.
Related Issues (20)
- Login authentication issue of token 403 error HOT 10
- Documentation and support for WebCrypto HOT 2
- Private key being escaped and duplicated when passed to hash_function
- Not to standard: Raw body is include in the signature base string
- Headers are inconsistent and/or not forming correctly with access token and access token secret HOT 2
- How to add oauth verify?
- 401 error - invalid oauth signature HOT 5
- oauth_verifier is missing HOT 3
- "Duplicate timestamp/nonce combination, possible replay attack. Request rejected." HOT 2
- TypeError: Cannot read property 'toUpperCase' of undefined HOT 4
- No oauth parameters supplied? HOT 1
- Signature Not Handling Complex Object Structure HOT 1
- TypeScript definitions should not have implicit any HOT 2
- oauth_signature does not match expected value in C# while get acess token in thmblr HOT 1
- oauth_consumer_key="undefined" in request headers HOT 1
- oauth in body not working with axios HOT 1
- How can a callback be specified in the Authorization header? HOT 2
- Verifying Signature helper? HOT 5
- CryptoJS include no longer available
- Index signature missing for OAuth.Header (typescript) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oauth-1.0a.