Giter Site home page Giter Site logo

javascript-sdk's Introduction

Cinchy Javascript-SDK

Installation

Add the cinchy.js file to your project and include the script in the html pages that use it.

Example:

<script src="js/cinchy.js"></script>

Please use v2.x.x of the library if you are using Cinchy v2.x.x and higher, otherwise, use v1.x.x.

Please use version 4.0.0 if you are using any Cinchy versions from Cinchy v4.0.0 to Cinchy v4.5.x.

Please use version 4.1.0 if you are using Cinchy versions Cinchy v4.6.0 and up.

Configure

To connect to Cinchy, you must configure the window's cinchyJS object in your javascript code:

window.cinchyJS = new CinchyJS({
    // The url of your Cinchy instance
    cinchyRootUrl: 'http://my.cinchy.url.co',
    // The identity server of your Cinchy instance
    authority: 'http://my.cinchy.url.co/cinchyssocore',
    // The client id for your applet
    client_id: 'javascript-sample',
    // (Optional) The requested scopes for the applet (must be permitted for the client)
    // You must have openid and id requested
    scope: 'openid id email profile roles',
    // (Optional) Enable silent refresh
    silent_refresh_enabled: true,
    // (Optional) (Mandatory if silentRefreshEnabled = true) The silent refresh url
    silent_redirect_uri: 'http://localhost:3000/silent-refresh.html',
    // The callback function that gets executed after login
    user_loaded_callback: initialize
});

Enabling Silent Refresh

In order to use silent refresh, you must:

1). Set the silent_refresh_enabled property to true in your CinchyJS object.

2). Add a silent-refresh.html file into your project. This can be found within the repo folder in the repo or copy & paste this (modify the script src location to where your cinchy.js file is):

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <script src="/js/cinchy.js"></script>
    <script>
        new Oidc.UserManager().signinSilentCallback().catch((err) => {
            console.log(err);
        });
    </script>
</body>
</html>

Silent refresh works by using a hidden iframe to access a url that contains the silent-refresh.html page. This iframe makes a request to the server to retrieve a new access token.

3). Add the silent-refresh url into the "Permitted Login Redirect URLs" field of the "Integrated Clients" table within Cinchy (eg. http://localhost:3000/silent-refresh.html).

License

This project is license under the terms of the GNU General Public License v3.0

javascript-sdk's People

Contributors

alvin-h avatar cinchy-yogeshjagtap avatar

Watchers

 avatar James Cloos avatar Nitin Jadhav avatar Cristian Deschamps avatar Greg K avatar

Forkers

tyrose1214

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.