Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Pinterest Auth with upload #2892

Open
wants to merge 6 commits into
base: development
Choose a base branch
from

Conversation

codedsun
Copy link
Contributor

Fixed #2292

Changes: Removed pdk client and added api endpoints for OAuth and upload

Screenshots of the change:

@codedsun
Copy link
Contributor Author

codedsun commented Oct 14, 2019

I am testing and facing too many request on pinterest server, so will complete this PR by tomorrow and also I will fix failing build and few bugs,

@codedsun
Copy link
Contributor Author

@yashk2000 @iamareebjamal I am stucked here from 2 days. I am uploading the image through multipart, i recieve error. I tried as they did implemented in pdk client, but that doesn't also works. I am getting failure with multipart. will update here

@codedsun
Copy link
Contributor Author

@iamareebjamal @yashk2000 Need your help, I am trying to call uploadimage api to pinterest

The curl call is

curl -X POST \
  'https://api.pinterest.com/v1/pins/?access_token=Au1G6EblcR8RaDYxB1k-asasasa' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Postman-Token: 230730c9-2843-4272-800f-f00998e84945' \
  -H 'cache-control: no-cache' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'image=@/Users/suneetsrivastava/Desktop/Screenshot 2019-09-14 at 6.03.39 PM.png' \
  -F 'note="Suneet"' \
  -F board=ssas/as

My function to create body in android is using volley

 private void buildMultipartContent(DataOutputStream dos, byte[] fileData, String fileName) {
        try {
            dos.writeBytes(twoHyphens + boundary + lineEnd);
            dos.writeBytes("Content-Disposition: form-data; name=\"image\"; filename="+fileName+lineEnd);
            dos.writeBytes(lineEnd);
            dos.write(fileData);
            dos.writeBytes(lineEnd);
            dos.writeBytes(twoHyphens + boundary + lineEnd);
            dos.writeBytes("Content-Disposition: form-data; note=\"suneet\"");
            dos.writeBytes(lineEnd);
            dos.writeBytes(twoHyphens + boundary + lineEnd);
            dos.writeBytes("Content-Disposition: form-data; board=\"basas/asas\"");
            dos.writeBytes(lineEnd);
            dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
            VolleyLog.e("Suneet - Multipart Created");
        } catch (IOException e) {
            VolleyLog.e("Suneet - Multipart Failed");
            e.printStackTrace();
        }
    }

The postman call works fine, I am not getting what's the issue

@codedsun
Copy link
Contributor Author

Please help me, I am stucked and not getting solution. I need to complete this last step to get the Pinterest account section get working.

@iamareebjamal
Copy link
Member

I have no experience with volley. Only with OkHttp and Retrofit

@prudhvir3ddy
Copy link
Contributor

@codedsun can you please explain why we have to use volley here? can't we go with retrofit ?

@codedsun
Copy link
Contributor Author

@prudhvir3ddy The project is using volley, not retrofit for api calls. If i would have used retrofit, might be the task would have been done

@codedsun
Copy link
Contributor Author

@iamareebjamal @prudhvir3ddy We are using a volley library that has been depreciated

https://github.com/mcxiaoke/android-volley

What shall I do now?

@iamareebjamal
Copy link
Member

Move to Retrofit

@codedsun
Copy link
Contributor Author

Moving to retrofit #2895

@yashk2000
Copy link
Member

@codedsun if the work related to this pr has been done, should I close it?

@codedsun
Copy link
Contributor Author

codedsun commented Nov 3, 2019 via email

@codedsun codedsun force-pushed the pintrest branch 4 times, most recently from 1e9a194 to 76030ee Compare November 4, 2019 21:11
@codedsun
Copy link
Contributor Author

codedsun commented Nov 4, 2019

@yashk2000 The work has been completed, please check

Also @iamareebjamal We need to get the secret key from app created on pinterest developer console and also a Pinterest_Auth State and redirect URI. These fields are to be kept same as that saved in developer console.

Thanks.

@iamareebjamal
Copy link
Member

iamareebjamal commented Nov 4, 2019

Make it so that if the keys are not present, the app doesn't crash

@codedsun
Copy link
Contributor Author

codedsun commented Nov 5, 2019

@iamareebjamal Done! @yashk2000 Please check

@codedsun
Copy link
Contributor Author

codedsun commented Nov 8, 2019

@yashk2000 Please check

@codedsun
Copy link
Contributor Author

@yashk2000 ?

@codedsun
Copy link
Contributor Author

@yashk2000 Also chcek this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failure to Authenticate Pinterest Account with Phimp.me
4 participants