#10 Android Login/Signup with MVVM - Passing Auth Token to Every API

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

ความคิดเห็น • 61

  • @ArastirmaHesap
    @ArastirmaHesap 6 หลายเดือนก่อน +1

    I have learned so many things from you! Thank you Belal Khan.

  • @ashar9327
    @ashar9327 4 ปีที่แล้ว +2

    Thank you so much ❤️ please make this course as long as possible 🥰 we support you

  • @ShakilAhmedShaj
    @ShakilAhmedShaj 4 ปีที่แล้ว +4

    17:00 Thanks for keeping my request brother ❤️❤️ As you said in (01:42), if we get 401 code, we will make the user logged out, so I am eagerly waiting to learn how we can get the network status code and do some operation based on those. thanks again for the efforts, eagerly waiting for the next videos. ( Also please try to handle atleast one network error response from the server, as like, if we give wrong user and password, how can we grab the error response with error response message from the server(response given by api) and show it to the user as like toast )

  • @krishnamandava9919
    @krishnamandava9919 4 ปีที่แล้ว +2

    11:37 Why we go for synchronous when asynchronous available?

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว

      Because here I need to return repository from the function. And I cannot make it suspending, it will require a lot of changes. As I told I planned to go with SharedPreferences.

    • @krishnamandava9919
      @krishnamandava9919 4 ปีที่แล้ว

      @@SimplifiedCoding Thanks but Why don't we use coroutine scope and make it asynchronous and another doubt is making synchronous is your personal decision or code demands?

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว

      @@krishnamandava9919 Code demands not possible to make it async here unless I do a lot of other changes. So I decided to do like this.
      Check this official doc
      developer.android.com/topic/libraries/architecture/datastore
      Check the use synchronous part here

    • @krishnamandava9919
      @krishnamandava9919 4 ปีที่แล้ว

      @@SimplifiedCoding Thanks man loved ❤️ for your explanation and answering to all comments and clearing doubts. That's why I daily checks TH-cam if there are any updates from @Simplifed Coding ❤️. I ignored that part in documentation last time so it created so many doubts in me. Keep posting videos make this series as long as possible and again ❤️

  • @warTag68
    @warTag68 2 ปีที่แล้ว

    1:13 I tested myself and this user endpoint always returns 200 status ok message, even if I make a request without token. it needs to be fixed

  • @SimplifiedCoding
    @SimplifiedCoding  4 ปีที่แล้ว +1

    If you want to use My API, then here are the details:
    Auth URL: simplifiedcoding.tech/mywebapp/public/api/auth/login or /signup
    User URL: simplifiedcoding.tech/mywebapp/public/api/user
    Here is a user that you can use for Login if you do not want to make the SignUp part on your own.
    email: probelalkhan1@gmail.com
    password: 12345678
    Thank You

  • @enrique12345-x
    @enrique12345-x 2 ปีที่แล้ว +1

    Hello friend, how would it be sending parameters to the UsersAPI, since my endpoint, apart from receiving the Token, in the Body I send parameters, I try to put the parameters but it does not make the call, I remove the parameters as well as the endpoint and yes makes the correct request. I hope you can help me and I have explained. kind regards (sorry my english is not very good) xD

  • @AakashJain90
    @AakashJain90 3 ปีที่แล้ว +2

    Thanks for the Video. One query:-
    Here, Fragment(a view) is directly accessing the sharedPreferences(data),
    Isnt it violate the basic principle of mvvm, where repository provide data to vm and then vm to view ?

    • @SimplifiedCoding
      @SimplifiedCoding  3 ปีที่แล้ว +1

      Yes it is violating that principle. May be I did it to make things quick. But in your side you should follow the principle.

  • @pheroqt1238
    @pheroqt1238 4 ปีที่แล้ว +1

    Hey Bilal, how do i get data in home fragment if I only use fetch user data for authentication? Is there any way to use 2 or 3 repos together?

  • @dhanu098765
    @dhanu098765 4 ปีที่แล้ว

    Hi Bilal, Would that be possible that you can create a video of the MVVM approach for the base activity class

  • @mridx
    @mridx 3 ปีที่แล้ว

    which one is the best place to store auth token (shared pref, datastore), and if we store in shared pref, is it okay to read the token everytime from shared pref before making an api call ??

  • @nikhilkatekhaye7773
    @nikhilkatekhaye7773 4 ปีที่แล้ว

    if you made changes for avoiding runblocking{ } as added code in basefragment then why you kept same changes in homefragment

  • @bhavnamulani8782
    @bhavnamulani8782 2 ปีที่แล้ว

    Hi Bilal,
    Can you please make a video on AppAuth Login Android basically using Kyecloak

  • @mojeebhasan5283
    @mojeebhasan5283 3 ปีที่แล้ว

    Pls make some video over flow api like how we can make multiple network request to the server using flow api because there is no such video on youtuble which deals with flow api with real world example when it comes to making multiple network request.
    I have one question. We all know coroutine works asynchronously right but my question is
    can we do some cpu intensive operation while we are waiting for response from server?

  • @Nikhil-bo5zt
    @Nikhil-bo5zt 2 ปีที่แล้ว

    I'm calling network call API as POST request with @Filed annotation but getting 404 error but as @Query I can able to run api but in case add one @Field parameter then only api getting success any idea. What happens here...

  • @امیرحسینكامرانپور
    @امیرحسینكامرانپور 2 ปีที่แล้ว

    where is the Token Authenticator class? I cant find in your playlist

  • @ArshadAli-hd4we
    @ArshadAli-hd4we 2 ปีที่แล้ว

    While running the app I am getting an error "lateinit property user preferences has not been initialized

  • @padmakargarg9720
    @padmakargarg9720 2 ปีที่แล้ว

    Thanks but how to get token header from api response & pass token another api header.please help me

  • @ManishPatel3030
    @ManishPatel3030 3 ปีที่แล้ว

    Awesome work 👍

  • @reyzer7032
    @reyzer7032 2 ปีที่แล้ว

    sir I get some error, lateinit property viewModel has not been initialized

  • @ChandrashekharNandanwar
    @ChandrashekharNandanwar 4 ปีที่แล้ว

    Hi Bilal, nice tutorial. I have gone through the complete tutorial playlist and learned a lot. I have one query regarding authentication. How to implement Rest Api call in android with basic authentication? I have a username, password, and API key to access API. please guide on this.

  • @sampputheburning5056
    @sampputheburning5056 4 ปีที่แล้ว +1

    can we use withcontext() instead of runblocking

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว

      Just try it and see 😉
      You cannot, you can only call withContext inside a suspending function. And we can't make our function suspending here.

    • @caronfernandes4625
      @caronfernandes4625 3 ปีที่แล้ว

      @@SimplifiedCoding why did you use run block instead of launch ?

  • @srikanthgutti2290
    @srikanthgutti2290 4 ปีที่แล้ว

    How to create observer in different fragment for same data ?

  • @hardkernel
    @hardkernel 4 ปีที่แล้ว

    Hi Bilal, thanks for your video.
    In introduction you said you have update your laravel API, where can we get the updated code source please ?

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว +1

      In the same repository, check api tutorial, link is in description

    • @hardkernel
      @hardkernel 4 ปีที่แล้ว

      @@SimplifiedCoding thanks, the tutorial on the website is not up to date, we must download the source code to have the lastest one

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว +1

      @@hardkernel yeah, repository is updated

  • @ahmadaffandi4996
    @ahmadaffandi4996 3 ปีที่แล้ว

    do you have the java language version?

  • @swethaaresetty3105
    @swethaaresetty3105 3 ปีที่แล้ว

    Hello ,
    I am creating an app which has two fragments , home and profile . Profile fragments shows the user data retrieved from database. When i open profile fragment for the first time , it is taking time to load the user data and when i switch to home fragment and again back to profile fragment , it is loading the user details again . Can anyone please tell me how to load the data first time then save it and restore it from next time using kotlin.

  • @i-am-learning-life
    @i-am-learning-life 4 ปีที่แล้ว +1

    Are you using hilt for di

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว +1

      DI is not used yet in this project.

    • @jayeshbanjara6090
      @jayeshbanjara6090 4 ปีที่แล้ว

      @@SimplifiedCoding Is there planning to add hilt in this playlist ?

    • @Venkatesh_Naidu_16
      @Venkatesh_Naidu_16 4 ปีที่แล้ว

      Dagger 2 , kodin or hilt ???

  • @lies137
    @lies137 4 ปีที่แล้ว

    it's great and all!! but I think it would be better if you showed us how to secure it !

  • @nilthenik123able
    @nilthenik123able 3 ปีที่แล้ว

    Receiving this error while running the application. app is running correctly till #9
    kotlin.UninitializedPropertyAccessException: lateinit property viewModel has not been initialized
    at com.kleem.casemanagement.ui.base.BaseFragment.getViewModel(BaseFragment.kt:25)
    at com.kleem.casemanagement.ui.home.HomeFragment.onViewCreated(HomeFragment.kt:26)
    Please help

    • @nilthenik123able
      @nilthenik123able 3 ปีที่แล้ว

      i've added OnCreateView method, post removing the same. It's working fine.

    • @reyzer7032
      @reyzer7032 2 ปีที่แล้ว

      @@nilthenik123able can you point it to me, or on your github, as I am also having the same problem with the viewmodel

  • @sureshk0606
    @sureshk0606 4 ปีที่แล้ว

    how to refresh token api call in this

  • @anwarpasha9278
    @anwarpasha9278 4 ปีที่แล้ว

    sir my apk is not loading Realtime database in release mode and crash my apk
    but the apk is work properly in debugg mode and loading my data in my app successfully
    i am also set my sha 1 key in firebase project and change the json file in android studio then the apk not working in release mode " app is keeps stoping"
    help me bro

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว

      Add crashlytics and check the crash message

  • @hulk2313
    @hulk2313 3 ปีที่แล้ว

    Here retrofit instance is created multiple times, because of that api is calling multiple times , How to avoid that

    • @SimplifiedCoding
      @SimplifiedCoding  3 ปีที่แล้ว

      Check this
      Android Hilt - MVVM Architecture and Dependency Injection
      th-cam.com/video/QfnmLx68jcI/w-d-xo.html

    • @hulk2313
      @hulk2313 3 ปีที่แล้ว

      @@SimplifiedCoding CHecked it but it is not handled there also. Here is similar problem github.com/square/retrofit/issues/2367

  • @rajusah3710
    @rajusah3710 4 ปีที่แล้ว

    How to ask for some permission using view model ?

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว

      You don't need to do it, permission is a UI related thing that you can do in activity or fragment.

  • @vivekpanchal
    @vivekpanchal 4 ปีที่แล้ว

    unable to get the source code your website is down i think

    • @SimplifiedCoding
      @SimplifiedCoding  4 ปีที่แล้ว

      Yeah working on it, try after few hours. Sorry for inconvenience.

    • @vivekpanchal
      @vivekpanchal 4 ปีที่แล้ว

      ​@@SimplifiedCoding thanks did you used navigation in this project? I was wondering how to make it work with base classes you made

  • @h.r.60
    @h.r.60 4 ปีที่แล้ว +1

    Amazing. Keep up the great work. More Please! 😁

  • @wavedass4655
    @wavedass4655 4 ปีที่แล้ว

    create a camera x tutorial for java

  • @fabioodiamante
    @fabioodiamante 3 ปีที่แล้ว

    hi, i have this problem
    2021-04-21 04:38:19.891 1399-6211/? E/InputDispatcher: Window handle Window{8593a93 u0 com.consertaki.profissional/com.consertaki.profissional.ui.activity.SignInActivity} has no registered input channel