Check Mobile App
Read now
Start a Project

Basic Authentication in Retrofit android

Save

Retrofit is a library which is type-safe REST client for Android. Type-safe means that the compiler will validate types while compiling, and throw an error if you try to assign the wrong type to a variable.

Before Reading this blog you have to read following blog to learn the basic knowledge of the Retrofit,

Using Retrofit library to make Http Requests

How to add Basic Authentication

Step 1: Make an interface,

 

Step 2: Create the AuthToken

Step 3: Create the Retrofit Client,

Step 4: Make your call,

call the Api with Basic Authorization,

Thanks for reading this blog, You have any questions or problems comment below.

Happy Coding. Stay Super.

 

 

 

 

 

 

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


4 comments

  • Igor Ganapolsky
    This is the first solution I came across on the net that shows how to send a simple authToken via Retrofit GET request. Thanks!
    • anchit (Moderator)
      Thanks for your kind words
  • Sachin
    I am getting 401 Error
    • anchit (Moderator)
      Hello,

      The 401 error means unauthorized.

      Make sure that you are using correct credentials to generate the AuthToken.

      You can take the help of the backend team of your project to look into this point.

  • css.php

    When I think in getting solutions for my Ecommerce Platform, I think of Webkul. They have been such a blessing in our business. We have spent thousands of dollars in support and modules from them. We love their support team. They work very closely with us, and they always go the extra mile when we need help.

    Michael Urresta

    Michael Urresta

    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home