API for Login and Signup

Dear Techie,
I m new to flutter technology, Currently I’m creating one flutter base app for customer.
Front End - Flutter (Dart)
Back End - Sql Server (Microsoft)

Actually i struck with functionality Login with API . I m having Login api but i dont know how to fetch the access token .
Can you guys help me out ?

Here is one method which provide authentication.

import 'package:http/http.dart' as http;

String pass='123456789'
String email='mrmodh10@gmail.com'

authenticate(String email, String pass) async {
    String myurl =
        "here pass your url";
    http.post(myurl, headers: {
      'Accept': 'application/json',
      'authorization': 'pass your key(optional)'
    }, body: {
      "email": email,
      "password": pass
    }).then((response) {
      print(response.statusCode);
      print(response.body);     

  }

In that response you will get access token.

Heyy @Vasanth_kumar ! As you can see above, he has portrayed an HTTP request using the http package. You can hit your login API in a similar manner.

You should first test your API using Postman and check if its working properly, your response.body should contain something like this:

{
   api_token: "<API_TOKEN>",
   message: "Logged in successfully!",
   success: true
}

You can then get the API token like this:

print(response.body[‘api_token’]);

Hope this helps :slight_smile: