Coder Social home page Coder Social logo

cafebazaarauth's Introduction

BazaarAuth

Using this library, you can always access your users without having to implement a local login. Firstly, this reduces uncertainty/lack of security and bot users due to its unified login solution. It also reduces the cost of user authentication by email or text message. Furthermore, you do not lose user’s history and data in your app after uninstalling or changing the device. In the first step, Bazzar gives you a unique user id for each user/app which remains the same forever. More fields of user’s information such as username, email and etc. will be available in the future after the addition of the user's permission feature.

To start working with BazaaAuth, you need to add it's dependency into your build.gradle file:

Dependency

dependencies {
    implementation "com.farsitel.bazaar:auth:[latest_version]"
}

How to use

To login the user, you need to create a CafeSignIn object.

val signInOption = CafeSignInOptions.Builder(SignInOption.DEFAULT_SIGN_IN).build()
client = CafeSignIn.getClient(
    context,
    signInOption
)

At the moment you can only retrieve the default information including accountID. More features features will be added soon. After creating this object, you can receive the user login intent by recalling the following method and guid the user to Bazaar login page.

val intent = client.getSignInIntentWithScope()
startActivityForResult(intent, REQ_CODE)

To parse the data from CafeBazaar and receive the account recall the following method in onActivityResult.

val account = CafeSignIn.getSignedInAccountFromIntent(intent)

In case user has granted the access the account returning value is not null and you can read data from accout model.

In case the user has already granted the login access to get latest data, use the following method.

CafeSignIn.getLastSignedInAccount(this, this,CafeSingInCallback { account ->
        updateUI(account)
 })

In case the user has already granted the login access,the account has a value otherwise it's null

In order to receive information by sync method , you can use the following method Caution: You are not able to call this method on the Main thread

val account = CafeSignIn.getLastSignedInAccountSync(this, this)

To display Bazaar login button in your application you can use the following View in in your XML

<com.farsitel.bazaar.auth.widget.LoginButton
    android:id="@+id/loginButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:size="NORMAL" />

The size value in this widget can be BIG or NORMAL which sets the button view size.

Security issues

To ensure that the correct version of Bazaar app is available on user’s device ( in order to prevent phishing and information theft ) use the following method.

CafeHelper.isBazaarInstalledOnDevice(context)

Bazaar in client device

To ensure that the user’s app version is capable of Bazaar’s login, use the following method.

CafeHelper.isBazaarNeedToUpdate(context)

If Bazaar app is not installed, you can use following method.

CafeHelper.showInstallBazaarView(context)

In case an update for Bazaar app is required, use the following method

CafeHelper.showUpdateBazaarView(context)

cafebazaarauth's People

Contributors

shayanpourvatan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.