Laravel user authentication in react-native? - javascript

I'm working on my first react-native app, coming from vue-laravel background I was wondering if it's actually possible to use laravel normal auth for my react-native, so far it seems I can succesfully login a user sending their credentials via POST request to my API, however subsequent uses of Auth helper fail, that is I can't get the logged user using Auth::user(), it returns null...
Is this possible to accomplish? I have read about firebase auth but I don't feel like adding another database system to my laravel main Mysql database, truth is I don't know for sure what laravel uses for authentication under the hood so I can't get this to work.
Any help would be appreciated.

You can use tymon/jwt-auth for backend (laravel) and use the token in frontend(react native)

Related

Laravel authentication in nativescript-vue app, anyone has done it?

I'm fairly new to nativescript-vue dev and I'd like to set authentication for my native app, I have been thinking about using firebase auth but I'd rather go the laravel route (if it's a good choice at all).
How I think I'd handle this is to send a post request to my backend (which is a laravel app) into my custom auth controller, then in the success callback I'd change isLogged in the vuex store to true or false, since I'm suing also vuex-persistedstate to persist some data into my localStorage (actually it's Application Settings in natviescript afaik).
Is my way of doing this okk? has anyone done it?
I was using a Laravel API before, but decided to switch back to Firebase, I think it’s a better choice for mobile.
But if you want to use Laravel, take a look at Laravel Passport (https://laravel.com/docs/6.x/passport).
You can use the Password Grant (https://laravel.com/docs/6.x/passport#password-grant-tokens) to generate a token from your mobile application, by creating a login endpoint that will generate the token for you.

Authentication Problem when using Twitter API

I have used Firebase to login to Twitter and generate token and secret that is needed auth in Twitter API (I think)
I have integrated Firebase with no errors and It works fine and returns both the values correctly.
Now I don't know how to implement these value and pass this token in twitter API. Please help with this (Javascript/React)
My problem is exactly this Same problem In PHP(from StackOverflow) except I used React instead of PHP and i have trouble understanding PHP code and implementing that logic to Javascript.
I also tried sending API request via Postman but I don't what fails.
You must pass headers and choose authorization.
You can use react-twitter-login package to get all tokens automatically, or look on codebase of it:
signature.ts - OAuth headers generation
oauth1 - OAuth 1.0 flow

Calling a django api from react for sign in page

I have built a react application which has a login page. I am done with the frontend of login page using react. Now the other person from my team has build a backend api on django. I want to call that api from my react code now. How should I do it? Do I need to learn something specific? I have searched in internet and all of the sources we to make serve react and django from same project. I have a React project with me and a separate api developed by someone else. Please guide me through this. I am pretty new to this.
No, you dont have to learn something new. You need to just make an ajax call to the API endpoint from within your react application to fetch or send the data needed and handle the response.
Also keep in mind to setup the ajax to send the CSRF token as shown in the docs.

ng-token-auth get logged in user

I am trying to make an angular app. I am using rails with devise_token_auth in backend. I am trying to setup the angular app with ng-token-auth.
I have read up everything I can find online for past whole week but still couldn't figure out how to get the user currently signed in.
I understand that auth:login-success event returns a user object.
I understand there is validateUser method which validates if auth token is present and is valid, and it is run on page load.
How do I retrieve the user whose token is present in storage or cookie on page load or at any other time, kind of similar to current_user in rails.
There dosen't seem to be any such thing in built in ng-token-auth.
How do I accomplish this.
Is there any flaw in my approach or assumption ?
I am learning angular by building an app and am REALLY stuck at this point.
Have you tried storing the user object in ngStorage and then doing calls with the auth token for that user?

Node.js + Ember.js Login System

I have a server running node.js and my client-side is in ember.js.
I'm trying to implement a login system but there is not much on the interner about these two tools working together. I've got a simple authentication system
But what I need to do is the $_SESSION part like in php.
I can login and get my information right away but I don't know how to remain logged in to forbid/allow to go trough certain pages. I need some cookies or something but not quite seeing how I'm going to do this with these two tools.
Thanks in advance
Here are two examples of handling sessions/authentication and login in ember
https://github.com/embercasts/authentication-part-1
https://github.com/embercasts/authentication-part-2
here is a ember-addon
https://github.com/Vestorly/torii
you can store the session token in a cookie, so that when the page is closed the application can retrieve it.
you can send the session token to your nodejs api to authorize the user to whatever resources you are using

Categories

Resources