Giter VIP home page Giter VIP logo

matrix-auth-swift-sdk's Introduction

MATRIX Swift Auth SDK

MATRIX Authentication framework for Swift

Build Status CocoaPods Compatible License Platform Swift

Requirements

  • iOS 8.0+
  • Xcode 8.1, 8.2, 8.3, 9.0
  • Swift 3.0, 3.1, 3.2, 4.0

Installation

CocoaPods

To integrate MATRIX Auth SDK into your Xcode project using CocoaPods, specify it in your Podfile:

    pod 'MatrixAuthSDK'

Then, run the following command:

$ pod install

Usage

The starting point is MatrixAuth. With it you can:

  • Authenticate an existing user and work with it via UserAuth
  • Create a new user with given credentials and a role
  • Request a password reset for a user, which they can then do via email

User Authentication

let auth = try MatrixAuth(clientId: ..., clientSecret: ...)
let username = "[email protected]"
let password = ...

auth.authenticate(username: username, password: password) { result in
    switch result {
    case let .success(user):
        // Do stuff with user
        ...
    case let .failure(error):
        // Authentication failure; handle error
        ...
    }
}

User Details

let user: UserAuth = ...

user.details { result in
    switch result {
    case let .success(details):
        // Prints the details of the user as returned by the AdMobilize API
        print(details)
    case let .failure(error):
        // Handle error
        ...
    }
}

User Device Secret

let user: UserAuth = ...
let device: String = ...

user.deviceSecret(for: device) { result in
    switch result {
    case let .success(secret):
        // Prints the secret for `device` belonging to `user`
        print(secret)
    case let .failure(error):
        // Handle error
        ...
    }
}

User Registration

let auth: MatrixAuth = ...

auth.registerNewUser(username: ..., password: ..., role: ...) { result in
    switch result {
    case let .success(value):
        // Do stuff with API response
        ...
    case let .failure(error):
        // Handle error
        ...
    }
}

User Password Reset

After this, an email will be sent to the user asking them to reset their password.

let auth: MatrixAuth = ...

auth.forgotPassword(username: ...) { result in
    switch result {
    case let .success(value):
        // Do stuff with API response
        ...
    case let .failure(error):
        // Handle error
        ...
    }
}

License

This project is released under the MIT License.

matrix-auth-swift-sdk's People

Contributors

nvzqz avatar

Watchers

Brian Sanchez avatar Sean Canton avatar Maciek Ruckgaber avatar James Cloos avatar Leonardo Vernaza avatar Andrés Felipe Calderón de Restrepo avatar  avatar Alie Gonzalez-Guyon avatar  avatar

Forkers

notyours180

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.