Closed mrose17 closed 10 years ago
base_url is a parameter I made up in case the API location ever changed; it doesn't need to be sent in the request! Try omitting that one parameter, and then you'll match what I have exactly. Also, be sure you're setting the Content-Type header to 'application/json' -- that's the only other thing you need for the auth request.
On Tue, Jan 7, 2014 at 9:31 PM, mrose17 notifications@github.com wrote:
here's what i'm sending in the post for /oauth2/token
{"client_id":"...","client_secret":"...","username":"mrose17@gmail.com","password":"...","grant_type":"password","base_url":"https://winkapi.quirky.com"}
and here's what i get back:
{"data":{"error":"unsupported_grant_type"},"errors":[],"pagination":{}}
eh? i've looked at your code and you're sending password as well. am i missing the obvious?
— Reply to this email directly or view it on GitHubhttps://github.com/jso/py-wink/issues/4 .
thanks. i removed base_url, and verified the headers:
{ protocol: 'https:',
slashes: true,
auth: null,
host: 'winkapi.quirky.com',
port: null,
hostname: 'winkapi.quirky.com',
hash: null,
search: null,
query: null,
pathname: '/oauth2/token',
path: '/oauth2/token',
href: 'https://winkapi.quirky.com/oauth2/token',
agent: false,
method: 'POST',
headers: { 'Content-Type': 'application/json' } }
so, i suspect that we're sending the same thing. odd.
Well, that's bizarre. I double checked, and this is what my interaction looks like. I don't see any difference.
Request URL: https://winkapi.quirky.com/oauth2/token
POST body: {"username": "_", "client_secret": "", "password": "**", "clientid": "**", "grant_type": "password"}
HTTP response headers: {'status': '201', 'x-request-id': '***', 'expires': 'Fri, 01 Jan 1990 00:00:00 GMT', 'transfer-encoding': 'chunked', 'strict-transport-security': 'max-age=31536000', 'x-runtime': '0.130222', 'connection': 'keep-alive', 'x-ua-compatible': 'IE=Edge,chrome=1', 'pragma': 'no-cache', 'cache-control': 'no-cache, no-store, max-age=0, must-revalidate', 'date': 'Wed, 08 Jan 2014 03:43:02 GMT', 'content-type': 'application/json; charset=utf-8', 'x-rack-cache': 'invalidate, pass'}
HTTP response body: {"data":{"accesstoken":"**","refreshtoken":"**","token_type":"bearer","token_endpoint":" https://winkapi.quirky.com/oauth2/token"},"errors":[],"pagination":{}}
On Tue, Jan 7, 2014 at 9:37 PM, mrose17 notifications@github.com wrote:
thanks. i removed base_url, and verified the headers:
{ protocol: 'https:', slashes: true, auth: null, host: 'winkapi.quirky.com', port: null, hostname: 'winkapi.quirky.com', hash: null, search: null, query: null, pathname: '/oauth2/token', path: '/oauth2/token', href: 'https://winkapi.quirky.com/oauth2/token', agent: false, method: 'POST', headers: { 'Content-Type': 'application/json' } }
so, i suspect that we're sending the same thing. odd.
— Reply to this email directly or view it on GitHubhttps://github.com/jso/py-wink/issues/4#issuecomment-31803378 .
thanks. i'll try a few more things and then email them tomorrow...
One really dumb idea but worth a shot -- maybe use the expanded JSON format with spaces? I know it should parse with or without them, but it might be the issue.
On Tue, Jan 7, 2014 at 9:48 PM, mrose17 notifications@github.com wrote:
thanks. i'll try a few more things and then email them tomorrow...
— Reply to this email directly or view it on GitHubhttps://github.com/jso/py-wink/issues/4#issuecomment-31803750 .
@mrose17 Email me a Charles web proxy session or a cURL command illustrating exactly what you're doing and I'll have a look.
many thanks! back in 5m.
@jso and @mattbornski - the repo is now public at https://github.com/TheThingSystem/node-winkapi
obviously, i'm doing something clueless here, but as to which clue i'm lacking, i'm not sure.
to test (on a system with node): edit test.'s to include "the needful" and then
% node test.js
ps: feel free to push requests or issue me at https://github.com/TheThingSystem/node-winkapi/issues
@mattbornski i found the issue and updated the repo.
the issue is that the Wink API server doesn't like the JSON generated by JSON.stringify(). as @jso suggested, putting some whitespace in there made the parser happy! onward...
here's what i'm sending in the post for /oauth2/token
and here's what i get back:
eh? i've looked at your code and you're sending password as well. am i missing the obvious?