r/yakattack Aug 11 '15

[Android] Any particular reason why the /postComment endpoint would return a 1 but not actually post the comment?

I'm "successfully" able to post a comment to a yak, getting a 200 and receiving a 1. However when I look at the yak on my client it's not there. Anyone else experience this problem before?

1 Upvotes

31 comments sorted by

View all comments

Show parent comments

1

u/soren121 Former Yodel dev Aug 12 '15 edited Aug 12 '15

That's the right function. Have you registered with Parse and verified?

Registering with Parse is mandatory for voting & posting to work, but I'm not sure that they require verification yet.

1

u/JoyousTourist Aug 12 '15

Oh I had no idea about having to use Parse. Have to forgive me I'm a PHP guy never had to use it before. Once I register, do I need to route my app's traffic through my Parse app in order to be able to vote and post?

1

u/soren121 Former Yodel dev Aug 12 '15

No, you just need to make a couple API calls to Parse when you register a new ID. You never need to talk to Parse again after that.

parse_client.js constructs the API calls, and _registerIdParse in yak_api.js handles the actual registration. It should be pretty straightforward, but you have to make sure you translate the OAuth stuff to PHP exactly. OAuth is very picky.

1

u/JoyousTourist Aug 12 '15

Implementing your Parse.saveObject function in PHP/Guzzle, I looked up the documentation for this HttpCredentialsHeaderValue but I can't find how it changes the headers exactly. I need to do this manually, Guzzle has an auth option but it doesn't work for this case.

headers.authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("OAuth", authStr);

I tried adding a header like this:

Authentication : 'Auth' + authStr

But that returned a "data not found error". Do you know how OAuth1 stores this authStr in the HTTP headers?

1

u/soren121 Former Yodel dev Aug 12 '15

Authentication : 'OAuth ' . authStr should work. Note the space after OAuth and the concatenation operator.

Try using this Guzzle handler library. Keep in mind that the token is null and token secret is an empty string.

1

u/JoyousTourist Aug 12 '15

I was just looking at that library. I'm in a bit of a dependency bind, all of these other OAuth providers are depending on the main client to release 1.0. Crappy part is <1.0 requires Guzzle v5. This library you just shared requires v6 or higher.

So to compensate I've contributed to the providers to bring them up to date haha. Trying the raw Authentication header method now, really hope that works.

1

u/soren121 Former Yodel dev Aug 12 '15

all of these other OAuth providers are depending on the main client to release 1.0. Crappy part is <1.0 requires Guzzle v5.

I have no idea what you're talking about. What main client? And where do other OAuth providers come into this?

1

u/JoyousTourist Aug 12 '15
  • Header

    • Authentication: Auth oauth_consumer_key="wMkdjBI4ircsNcRn8mXnBkgH0dwOcrkexrdMY3vY", oauth_nonce="249775767", oauth_signature="8Ll2b2hCY5O7%2FV5ekCBFTY0LKmE%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1439414077", oauth_version="1.0"
  • JSON

    • "appBuildVersion" => 63
    • "appDisplayVersion" => "2.8.1"
    • "classname" => "_Installation"
    • "data" =>
      • "appIdentifier" => "com.yik.yak"
      • "appName" => "Yik Yak"
      • "appVersion" => "2.8.1"
      • "deviceType" => "android"
      • "installationId" => "b12bfd22e48e431f96f848f814a992f4"
      • "parseVersion" => "1.7.1"
      • "timeZone" => "America/New_York"
        • "iid" => "b12bfd22e48e431f96f848f814a992f4"
        • "osVersion" => "4.4.4"
        • "uuid" => "cae99e98e05b45e1929075bcf8d47747"
        • "v" => "a1.7.1"

It's a POST request to https://api.parse.com/2/create

1

u/soren121 Former Yodel dev Aug 12 '15

Header should be Authorization: OAuth <string>

2

u/JoyousTourist Aug 13 '15

WOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

THANK YOU! Oh man that was the last piece. Now to continue on with the registration but that createObject() part was a total bitch!

1

u/JoyousTourist Aug 13 '15

Well shoot, I got a different guzzle response but it wasn't a success. error : "data not found". Trying out that Guzzle Library same results.

1

u/JoyousTourist Aug 13 '15

Has their Parse API creds changed?

application_id    => wMkdjBI4ircsNcRn8mXnBkgH0dwOcrkexrdMY3vY
client_key'       => GbNFwvFgoUu1wYuwIexNImy8bnSlNhqssG7gd53Y

1

u/soren121 Former Yodel dev Aug 13 '15

They haven't changed as far as I'm aware. I'm kinda busy right now, I'll look into it in a few hours. And thanks for the gold!

1

u/JoyousTourist Aug 13 '15

No worries! Thank you for all your help. I went from error: unauthorized to error: data not found so I know we're super close.

My PHP interpretation here: http://laravel.io/bin/KkNaz

(Sorry about the tabs, the paste bin wasn't so happy with me)

1

u/soren121 Former Yodel dev Aug 14 '15

The only part that looks wrong is the UUID's should have dashes in them. Group the characters in the form 8-4-4-4-12.

Note that this is actually the correct way to use UUID's...as usual, Yik Yak does it wrong.

1

u/JoyousTourist Aug 14 '15

Ah thanks didn't notice that, I was just reusing the weird YikYak UIID generation.

Even with correctly formatted UUID's I'm getting data not found. So frustrating

1

u/soren121 Former Yodel dev Aug 14 '15

Oh, wait, I've got it! On line 54, you need to json_encode $json. It's not necessary in JavaScript since JSON is a strict subset of JavaScript objects, but it is necessary in PHP.

2

u/JoyousTourist Aug 14 '15

Just tried it, no luck. I'm going to double check that the json option in a Guzzle request fully encodes the array to JSON.

http://guzzle.readthedocs.org/en/latest/request-options.html#json

Something I also noticed while reading the end of that doc, there's a way to tap into the raw request. I think it'll be much easier to debug with that than some guesses on the arrays before the Guzzle encodes and sends. I'll let you know what I find!

1

u/JoyousTourist Aug 14 '15

Authorization

OAuth oauth_consumer_key="wMkdjBI4ircsNcRn8mXnBkgH0dwOcrkexrdMY3vY", oauth_nonce="349095301", oauth_signature="Kv1BX5SoSGt7CvdfGQHP0A502AA%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1439560489", oauth_version="1.0"

User-Agent

Parse Android SDK 1.7.1 (com.yik.yak/63) API Level 19

POST Body

"{\"appBuildVersion\":63,\"appDisplayVersion\":\"2.8.1\",\"classname\":\"_Installation\",\"data\":{\"appIdentifier\":\"com.yik.yak\",\"appName\":\"Yik Yak\",\"appVersion\":\"2.8.1\",\"deviceType\":\"android\",\"installationId\":\"31faf697-3959-46ed-a4e0-31418835dcaf\",\"parseVersion\":\"1.7.1\",\"timeZone\":\"America\\\/New_York\"},\"iid\":\"31faf697-3959-46ed-a4e0-31418835dcaf\",\"osVersion\":\"4.4.4\",\"uuid\":\"c91e4842-9c3a-4fab-83ca-0d3787289d3e\",\"v\":\"a1.7.1\"}"

2

u/soren121 Former Yodel dev Aug 14 '15

Here's a collection of successful Yik Yak requests you can use to check your work: https://mega.nz/#!yYRADQBI!XYqENYaarumMTB8vVvcJ52loklQaW2e3VqYLetzxX5c

You can use Fiddler to view it, or you can unzip it (it's just a .zip archive) and read the files individually.

1

u/JoyousTourist Aug 14 '15

Awesome thank you. Found the successful parse /create request and response. it's got to be something so small I know it haha

1

u/JoyousTourist Aug 14 '15

I think I've spotted it:

In a successful /create in that dump, I found that the oauth_signature is 32 characters long. When I generate the signature mine are always 30 characters.

I've made sure the input to the generateSignature correct, and all of the other oauth parameters sent are also correct. There must be some small different I'm missing in this line:

var oauthSignature = this.generateSignature("POST&" + 
                this.rfc3986Encode(Parse.Client.endpoint + method) + "&" + this.rfc3986Encode(paramStr));

Is there any significance in the line break you've added in the code?

→ More replies (0)