AngularJS Getting Started
This will guide you through setting up and managing authentication and authorization in your JavaScript apps using cidaas SDK.
Click here for Sample Project.
First Get Your Credential
Once you are registered with cidaas, you can able to create your own Apps. Register with cidaas Try Now. Click here to know the steps to create Application.
There are some details about your Application that your application needs to know about properly communicate with cidaas, including your Client ID and Client Secret. You can retrieve these values from the settings area for your Application in the cidaas App Settings page.
Setup Your Callback URLs
Basically a callback URL gives directions to an external system on where to go next. What is at that URL could be anything.
You need to whitelist a callback URL for your app in the Callback URLs field in your Client Settings. If no callback URLs are set, a mismatch error will be displayed when a user logs in.
The Callback URL should be set like
http://www.myhostname.com, http://localhost:9000
Scope Management
Basically a scope management gives additional level of permissions or access rights for each user,as per the business requirements of the customer, using the scope - parameter.
cidaas checks to ensure that the defined scope matches with the actual scope allowed for the user, and appropriately grants access to the registered/logged in user.
Click here to know the steps to setup Scope Management.
Getting Script
Once you created the Application successfully, you will get the script of your application from our cidaas AdminUI.
Install Cidaas SDK
Integrate your application with cidaas you requires our cidaas_sdk.js library. You can retrieve this library from cidaas CDN.
Copy the script from your adminUI and paste it to the app where you want to integrate.
<script type = "text/javascript">
if (typeof window.cidaas !=='object')
{
window.cidaas = {};
}
cidaas.client_id = '<<app_client_id>>';
cidaas.login_redirect_url = '<<app_login_redirect_url>>';
cidaas.register_redirect_url = '<<app_register_redirect_url>>';
cidaas.response_type = '<<app_response_type>>';
cidaas.mode = '<<app_mode>>';
cidaas.extra_queries = '<<app_extra_queries>>';
cidaas.service_url = '<<app_service_url>>';
cidaas.userinfo_callback = function(userinfo)
{
};
</script>
<script type="text/javascript" src="https://cdn.cidaas.de/javascript/test/cidaas_sdk.js">
</script>
Secure Login and Register
You can simply call the doLogin() method where you want to implement the login functionality. For window mode Login you can call thedoWindowLogin(width,height) method.
<button (click)="doLogin()">Login</button>
The login functionality will work with the scope cidaas:login , this scope will add default when you create a new Application.
You can simply call the doRegister() method where you want to implement the register functionality. For window mode Registration you can call the doWindowRegister(width,height) method.
<button (click)="doRegister()">Register</button>
Like Login functionality, Register also work with the scope of cidaas:register.
User Profile
Basically user profile gives a requirement to retrieve and show profile information and You can manage (e.g. your password, email address, avatar image) in your user profile to the authenticated user.
You can simply call the cidaas.userinfo_callback(userinfo) method to retrieve the user personal information as JSON fromat.
cidaas.userinfo_callback = function (userinfo) {};
Logout
This logout provide to end access to your website. Logging out informs the website that the current user wishes to end the login session.
You can simply call doLogout() method to inform the current user login session end.
<button (click)="doLogout()">Logout</button>