Facebook Api Last Login
I am trying to login to my website using my Facebook account but Facebook is giving name and id only that is not enough to login user. Before I was getting full information like firstname, lastname, email etc.
facebook api last login
List of experiment variants for the player. Note that these variants are not guaranteed to be up-to-date when returned during login because the player profile is updated only after login. Instead, use the LoginResult.TreatmentAssignment property during login to get the correct variants and variables.
The Meteor Accounts system builds on top of the userId support inpublish and methods. The corepackages add the concept of user documents stored in the database, andadditional packages add secure passwordauthentication, integration with third partylogin services, and a pre-built userinterface.
The basic Accounts system is in the accounts-base package, butapplications typically include this automatically by adding one of thelogin provider packages: accounts-password, accounts-facebook,accounts-github, accounts-google, accounts-meetup,accounts-twitter, or accounts-weibo.
If the autopublish package is installed, information about all userson the system is published to all clients. This includes username,profile, and any fields in services that are meant to be public(eg services.facebook.id,services.twitter.screenName). Additionally, when using autopublishmore information is published for the currently logged in user,including access tokens. This allows making API calls directly fromthe client for services that allow this.
Optional callback. Called with no arguments on success, or with a single Error argument on failure. The callback cannot be called if you are using the "redirect" loginStyle, because the app will have reloaded in the meantime; try using client-side login hooks instead.
An email address that the external service will use to pre-fill the login prompt. Currently only supported with Meteor developer accounts and Google accounts. If used with Google, the Google User ID can also be passed.
Login style ("popup" or "redirect", defaults to the login service configuration). The "popup" style opens the login page in a separate popup window, which is generally preferred because the Meteor application doesn't need to be reloaded. The "redirect" style redirects the Meteor application's window to the login page, and the login service provider redirects back to the Meteor application which is then reloaded. The "redirect" style can be used in situations where a popup window can't be opened, such as in a mobile UIWebView. The "redirect" style however relies on session storage which isn't available in Safari private mode, so the "popup" style will be forced if session storage can't be used.
External login services typically require registering and configuringyour application before use. The easiest way to do this is with theaccounts-ui package which presents a step-by-step guideto configuring each service. However, the data can be also be enteredmanually in the ServiceConfiguration.configurations collection, whichis exported by the service-configuration package.
Login service configuration is sent from the server to the client over DDP whenyour app starts up; you may not call the login function until the configurationis loaded. The function Accounts.loginServicesConfigured() is a reactive datasource that will return true once the login service is configured; you shouldnot make login buttons visible or active until it is true.
Usually, the popup-based flow is preferable because the user will not have to reload your whole app at the end of the login flow. However, the popup-based flow requires browser features such as window.close and window.opener that are not available in all mobile environments. In particular, we recommend using Meteor.loginWith( loginStyle: 'redirect' ) in the following environments:
To ask the user for permission to act on their behalf when offline, map the relevant external service to true. Currently only supported with Google. See Meteor.loginWithExternalService for more details.
This is an updated version of a post I did last May on the topic of jwt auth with Angular 2+ and ASP.NET Core Web Api. That post was based on ASP.NET Core 1.x so it's a little dated and not as relevant now since everyone is hacking on .NET Core 2.0 which brought changes to both the Identity membership system and jwt implementation.
So, here's an updated guide on implementing user registration and login functionality using ASP.NET Core 2 Web API and Angular 5. As a bonus, I see lots of folks wondering how to include social login with token-based web api authentication and spa apps (no cookies) so I have implemented Facebook login in this demo to show a potential approach of how this could be done.
The last piece to add was the JwtFactory which is just a helper to create the encoded tokens we'd like to exchange between the client and backend. This happens in GenerateEncodedToken() which simply creates a JwtSecurityToken with a combination of registered claims (from the jwt spec) Sub, Jti, Iat and two specific to our app: Rol and Id. We're also using values injected from the JwtOptions we set up in the previous step.
I tested this action using postman to make sure I got the expected response when sending valid and invalid credentials to the authentication endpoint. Using the email@example.com account we created earlier I set up a post request to /api/auth/login and voila - authentication passes and I get a fresh JWT in the response.
To test the controller authorization I used postman once again to create a GET request to the /api/dashboard/home endpoint. I also included a request header containing the JWT token we created in the previous login test. The header key is Authorization with a value formatted as Bearer xxx where xxx is the JWT. Issuing this request the Web API responds with a 200 OK status and some secure user data in the body.
At this point, we've completed the majority of the backend. The remaining bits are for Facebook login which we'll look at shortly. First, we'll build out the frontend in Angular to see how JWT authentication works in a real application.
Note that in the login() method we're storing the authorization token issued by the server in the users' local storage via the localStorage.setItem('auth_token', res.auth_token) call. We'll see shortly how to use the token to make authenticated requests to the backend api.
With the component and service ready, we have all the pieces to complete the user registration feature. The last few steps involved adding the form markup to registration-form.component.html and binding the submit button on the form to a method in the registration-form.component.ts class.
This method is pretty simple, it's just calling userService.register() and passing along the user data then handling the observable response accordingly. If the server-side validation returns an error it is displayed to the user. If the request succeeds, the user is routed to the login view. The isRequesting property flag triggers the spinner so the UI can indicate that the app is busy while the request is in flight.
Here we just call userService.login() to make a request to the server with the given user credentials and handle the response accordingly. Again, either display any errors returned by the server or route the user to the Dashboard component if they've successfully authenticated. The check of valid is related to the form validation provided by the ngForm directive in the form markup. I won't cover this in detail but check out the code to get a better understanding of binding and validation in Angular provided by NgForm.
isLoggedIn() is a little naive as it just checks for the presence of the JWT in the browser's localStorage. If it exists, we assume the user is logged in by returning true. If it is not found, the user is redirected back to the login page.
Now that we have some level of authorization in place on the frontend, the last thing we want to do is start passing our JWT back to the server for Web API calls that require authentication. This is where we'll be utilizing the ApiAccess authorization policy we created and implemented earlier in the DashboardController.
The guide up to now has been based on standard credentials-based user registration and authentication directly with the ASP.NET Core Identity system. Now, we'll see how to incorporate a Facebook login flow into our app so users can signup/login directly with their Facebook credentials and gain access to the secure regions of the application.
The approach I'm showing here is quite simple. Basically, instead of relying on the ASP.NET Core Identity provider to authenticate the user's credentials as we do in the email flow we will integrate with Facebook's OAuth api and if login succeeds there we'll issue the user a JWT on our end which effectively logs them into the application.
To add Facebook's browser-based login flow to the existing UI I created a new facebook-login component. The UI template is pretty simple, it's just a button that will invoke the login dialog to begin the process.
This will open a new dialog window with Facebook's login page. From there, the user carries out the login process by entering their Facebook creds and connecting with the application. When complete, Facebook will redirect back to our application where we must carry on processing the response to determine if login succeeded and take the appropriate action. The redirect in the demo is handled by facebook-auth.html.