facebook manual login and share and get surrent user details - javascript

I'm creating a firefoxOS application using jquery mobile and cordova.There is no api in cordova for integrating facebook and firefox applications.
I have created a app in facebook and since there is no platform for firefoxOS,I have selected "website" as my platform.The problem is that there is no url for my firefoxOS application(only index.html),that I can give as redirect url in app settings page of developer.facebook .And also the I have followed steps from this URL (//developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.3) and its working fine in the browser as I'm able to login and share and get user details.
But when i copy/paste the code in my firefox project's index.html,the SDK does'nt seem to loading as none of the functionality is working.
Apart from the above trial,I have done the "login" flow manually by using this URL window.open("//www.facebook.com/dialog/oauth?client_id=APP_ID&response_type=token&redirect_uri=//MY_LOCALHOST/NAME/success.html").I'm able to access the current user's ACCESS_TOKEN from the success.html which is in server,but unable to access it in my index.html(as it is not hosted anywhere).I have tried to use localStorage,sessionStorage,cookies in success.html . I was wondering if there is any way of getting the current user's ACCESS_TOKEN after i have logged in.
I have used this URL https://graph.facebook.com/oauth/access_token?client_id=&redirect_uri=&client_secret=&code= (from //developers.facebook.com/docs/facebook-login/access-tokens) but it didnt help as I will be getting the access token which is redirected to success.html page which is in server.I need the ACCESS_TOKEN so as to pass as a parameter to this url https://graph.facebook.com/me?fields=id,name,email,picture&access_token=ACCESS_TOKEN in order to get the details of the user currently logged in .
But I'm able to share perfectly using this URL window.open("//www.facebook.com/dialog/feed?app_id=APP_ID&link="+encodeURIComponent(urlPost)+"&caption=&description="+encodeURIComponent(message)+"&redirect_uri=MY_LOCALHOST/NAME/success.html")with respect to the user logged even without the access_token (I dont know how its posting to the wall of the current user)
Is there any solution for the above problem? Thank you!!

Related

Expo - Is it possible to verify a user email on signup from firebase? (the link that firebase sends to an email doesn't redirect back to my app)

I am using Expo Go currently in development and can't find a solution to this anywhere...
I’m trying to use firebase.auth().sendSignInLinkToEmail(email, { url: // I don't know what url to put here to redirect user back to my app }) || I want to send a verification email to a new user but I can’t find anyway to redirect the user back to my Expo Go app from the email link that is sent. I can’t use exp:// or another scheme because I have to use a domain name that I can put in google's authorized domains within firebase. I have also tried auth.expo.io/#myusername/myproject but this only redirects correctly back to my app when using Expo's AuthSession for logging users directly into my app with credentials.
Please someone send some light on this!

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!

Single Sign On Html Page with Restful Service

Let me explain what's my plan.
Actually I write a website in HTML5 with Javascript.
This website do an ajax call to a c# RESTful service.
Both, the website and the service, are located on a windows server 2012 at the iis 8.
The website is located in an virtual directory of the default web site.
The service is added as an application to the server.
The server is running inside our intranet including AD.
I access the website by the url: http://example/Auth.
My goal is that the user didn't have to login manually, because it's already done at windows login.
This should be done by using windows authentication i guess, but when i activate it, i'm prompted to enter my credentials.
After entering them everything works fine. If they were correct i can use the website, otherwise i get 401 as expected.
First question: what do i have to do, to be logged in automatically if i'm a valid user of the AD?
Wheter logged in automatically or manually i'm not able to get the username of the logged in user and pass it to the service.
Second question: how to get the username and pass it to the server?
In my case it was finally quite simple to solve my problem.
All i had to do, was to add the domain to the url and get a full qualified url like: example.mydomain.com/Auth.
If i try toaccess this site now, there is no prompt shown and even the credentials get passed to auth following services etc.

How to get facebook user ID or name without Facebook Application

I'm working on web app which is NOT a Facebook Application.
I want to get current logged user's ID (I'm not sure if this is the right expression, I mean facebook.com/userid ) or user's name using Javascript.
Please if you don't know how to do it or if you don't have any suggestion what should help me, don't comment , thanks.How can I do this?
You cannot get the details (facebook id etc.) of the currently logged-in facebook user without using an app.
To query for the current user, you'll have to query for the /me and that requires an active access token which you can only get when the user authorizes an app!

Redirect URL using phonegap

I'm building a phonegap app in which I need to link to facebook, instagram and twitter. I need to allow users to login to each of these with their credentials and return an access token which I will be saving on the device using local storage. I can login the users perfectly fine when working on an actual site (which is a test site I have setup). The way it works is I have to redirect the user to a login page for each brand where they can login. This I can do fine from a phonegap app, but the issue is that each of them require a redirect url which I must supply for them to basically send the access token to once the user logs in. On the internet this works perfect, but I need to redirect url to somehow point back to the mobile device it originated from. I can do this using a proxy but I don't want to employ the use of a server as this comes with way to much overhead. So all that to actually ask my question:
How the heck do I redirect the user back to the mobile app after they have successfully logged in? I'm hoping this is something very simple that I'm missing, but I'm just not seeing it. :/
This is oAuth authentication which logs the user in and then tells the user's browser to go to the second URL. Typically, if you write an iOS app, you can always open it by doing something like this: ://. it should also be able to ready parameters passed this way.
For example: open safari on your iPhone and put "Skype://" as the address and it should open your skype app if you have it installed.
Try setting the return URL similar to what I mention above and see if that works.

Categories