Skip to content

Authentication

The authentication module does offer you a full authentication service, which you can adapt to your existing application. Simply import the module and start using the functions.

Get started

To install the package, just add the following line in your existing pubspec.yaml file under dependencies:

dependencies:
    schmucklicloud_auth: <SELECT THE NEWEST VERSION>

After that, just install the package on your local machine via the command:

pub get

Setup in your project

To use now the package on your new or existing project, just import the package in your Dart files. Create then a reference of the sCAuth class and you are ready to use the authentication service from schmuckliCloud.

//Import the package
import 'package:schmucklicloud_auth/main.dart';

//Setup a referene
sCAuth auth = new sCAuth("<YOUR_APP_ID>", "<YOUR_APP_SECRET>");

Authorize the user

To make the user able to sign in into your application, you have first to create a form for him, where he can enter his email and password. Send these two values then unencrypted and unhashed to the following function.

auth.authorizeEmailPassword(email, password).then((response) {
    if(response is Response) {
        var data = jsonDecode(response.body);
        if (data["status"] == 200) {
            //The login was successful

            //Get now the session token from the body;
            var session_token = data["body"]["session_token"];

            //Save the session token somewhere secure on the device, where you can access it across your application.
        }
    } else {
        //The response is an error
    }
});