How to upload image from a URL to server using Angular-upload? - javascript

Here is the scenario, in my application, user logs in through their Facebook account, after Facebook authorization, I receive user's profile information, including a url to their profile picture, and on the next page I fill some parts of my form using the info I've received from Facebook Graph API.
My question is how can I upload user's profile picture as the main picture of their account in my application as I'm getting only a URL to that picture from Facebook API ?
Please note that I'm using AngularJS and a plugin to handle uploads, called Angular Upload.
I'm totally open to any suggestions or other workarounds.
Thanks in advance.

Related

how to authenticate user with firebase on frontend

I am a frontend developer and i have given a project where i need to build a web gallery where user will sign-in with google oAuth. The Gallery will show pictures which user has uploaded. and user will be able to share the link of their photos so other people can see it.
What i am doing is that i have two html files. One is index.html and the other is gallery.html. Index.html will be the login page and from where the user will sign-in the gallery. The gallery will show pictures depending upon the url for example if the url looks like https://website.com/gallery.html?uid=<some_id_here> i grab the uid which is user id in firebase. Runs a function which gets the pictures from firebase firestore. And then i check if the uid in the address matches the current logged-in user uid. If yes then i add's the functionality of deleting the image in the gallery.
The main point is that i check the id in the address with current user id to see if the user owns the pictures or the gallery. I am not into backend i have started learning nodejs and express and few days ago and don't know how to authenticate user and stuff. So if this is a bad practice let me know and tell me what approch should i use instead.

Vimeo App to allow end users to upload to the owner's account via API

We are building an application based on Vimeo, where we would have one main account to hold all the uploaded content, and some members that are marked as contributors should be able to upload to this account via the vimeo api. What I am trying to achieve is that each contributing user would go through oauth authentication and use their access token to upload. This way we could see who uploaded which video.
I have been struggling to achieve this for days now. I have the upload access from Vimeo for my app, but when i would like to get an access token using the authorization code grant with the upload scope to my user I get the following error:
This app cannot generate a token with the upload scope for the requested account. This app can only upload to the app owner's account.
Which is weird considering that is precisely what I am trying to do. If I do not give the upload scope, my upload gets rejected with 403 Forbidden stating the user does not have the upload scope.
What am I doing wrong, or what would be the correct way to achieve this?
Thanks guys

How to show a file download link in my website if the visitor is logged in with Firebase authentication?

How to show a file download link in my website if the visitor is logged in with Firebase authentication?
I can use the JavaScript if (user) for checking if the user is signed in. But if I use
if (user){
document.getElementById('download_link').style="display:block;}else{document.getElementById('download_link').style="display:none;}
,
The visitors can simply get the the download link without signing in by getting webpage source code.
I've integrated firebase authentication and in every of my web pages, I want the download link to be only shown if the visitor is a logged user.
If I use simple css display:none with JavaScript if(user), then visitors can simply get the link by entering view-source: {site_url} is the browser address bar.
Please help

Dropbox redirect URI does not redirect for login, instead returns code of last user

I am using Dropbox Code API version 2 from NodeJS application. I am using OAuth 2.0 with code grant approach. It seems to behave randomly. The use case is as follows:
My server generates a redirect uri and sends to my client.
User clicks on redirect uri from client.
Application redirects to Dropbox URI. (User has already linked my app to their Dropbox. My app has full Dropbox permission.)
Dropbox asks to sign in with google or email. I used gmail.
Dropbox calls the registered callback with the code. I use the code to retrieve bearer token.
Problem: now i try to register another user and require a different code from Dropbox. The problem occurs in step 3. After
user clicks on step 3, Dropbox does not show the sign-in with
google or email page, instead, calls back application with the
same code as for user 1.
I'm using the same machine for testing this scenario and two different gmail addresses. My server runs on localhost. It was working before but stopped working without any intentional changes from me. I have tried debugging but I am not sure why this is happening, trying restarting client, server, even restarted my computer. But it doesn't show me the sign-in with google or email page.
My question is how does Dropbox know that it should show the sign-in page when the redirect link is clicked. I generated the redirect link using core API functions.
Maybe there is an error in my workflow, I am new to web development and have tried everything I know, any insight would be greatly appreciated.
Thanks!

Can I use the facebook feed dialog to post raw image data?

I am generating a png using the html5 canvas element, so I have raw data in the form of a data:image url... Is it possible to use this data to post a picture to a facebook wall?
I'm assuming the answer is 'no', as I receive the following error:
API Error Description: The specified URL is not owned by the
application
It does upload the image, apparently, as I'm on a slow coffee-shop connection and can watch the upload percent slowly complete.
I'm using the feed dialog because I'd prefer not to have a separate app that required auth...
When you create a application on facebook developer portal you will be asked to give a url of your app, this means when you take data, such as pictures, json or whatnot, this domain name is allowed, if you enter www.me.com as your app domain and then create a url/picture for a feed submission you have to use the same url and not www.someoneelse.org because the sdk uses the app profile as reference. security checks and whatnot.

Categories