onymos-logo
access icon

Quickstart Guide: Access Component

Access Component

Select a framework to get started.

Get started

Using Ionic or Cordova? Get the Access component working in your app in four easy steps.

  1. Download the component
  2. Add it to your environment
  3. Using Access
  4. Troubleshooting

1. Download the Onymos Access component

Sign up! We’ll send you a link to your component, set up your Onymos Cloud Account, and generate your Onymos license credentials. In the meantime, you can get familiar with our API Documentation and developer resources, or join a whole community of developers building apps with Onymos on Reddit!

2. Add it to your environment

Add your components to a folder in your app’s root (e.g., onymos_components).

Add the Onymos Initialize component to your environment.

$ ionic cordova plugin add onymos_components/onymos-component-initialize

Then we can add the Onymos Access component.

$ ionic cordova plugin add onymos_components/onymos-component-access --variable IOS_URL_SCHEME --variable FB_APP_ID

Then update the widget inside your config.xml with the Onymos Widget ID you receive after you create an Onymos Cloud Account.

3. Using Access

Using the Access component in your app
Want to sign-in users with their Apple, Facebook, or Google accounts or use email and password combinations stored in the Onymos Cloud? Want to use your own database or integrate with other OAuth 2.0 providers like Microsoft Azure? The Onymos Access component is a dynamic tool for authenticating your users in all of these ways!

Before we use Access, let’s make sure we have everything we need to configure your onymosConnectObject. The onymosConnectObject requires the appropriate Onymos license credentials: your Customer ID (also called an Onymos ID) and your Onymos Auth Token. You’ll need these credentials to use this (or any) component in your app. To generate your Onymos license credentials, create an Onymos Cloud Account.

NOTE: Your Onymos Auth Token will work with any number of apps and components. Onymos has a developer—and project—friendly pricing model. You can use any or all of our components in an app at no cost until they’re installed on 100 or more devices. This is ideal for iterating your MVP (see detailed pricing here).

Access component settings
In this Quickstart Guide, we’ll use Apple, Facebook, and Google to authenticate your users, but Access has even more functionality—and you’ll need to decide how much of it to use in your app.

Social Sign-in
Access includes support for Apple, Facebook, and Google social sign-in.

Apple: To use Sign In with Apple, you’ll need the IOS_URL_SCHEME value provided by Onymos. Make sure to also add “Sign in with Apple” as one of your app’s capabilities inside your XCode.

Facebook: To use Facebook Login, you’ll need the FB_APP_ID value provided by Onymos.

Google: Support for Google Sign-In requires you to provide a SHA-1 key for Android devices. You can find out how to generate your key and add it to your Onymos Cloud account here.

Email and Password System
Access offers a framework for creating and managing your own email and password sign-in system. You can reach out to customersuccess@onymos.com to learn more.

0Auth 2.0
Access can be used as an OAuth 2.0 client. You can authenticate against existing systems like Ping, Auth0, and ActiveDirectory. Contact customersuccess@onymos.com to find out how to integrate with your OAuth 2.0 client.

DataStore
Access needs server-side data storage for an email and password system. As part of the component offering, you’ll receive connectivity to the Onymos Cloud and 200 MB of storage.

All set? Let’s go inside your Ionic app’s app.component.ts file and initialize Access.

 import { Component } from '@angular/core';
 import { Platform } from '@ionic/angular';
    
 declare var OnymosInitialize: any;
 declare var OnymosAccess: any;
    
 @Component({
   selector: 'app-root',
     templateUrl: 'app.component.html',
     styleUrls: ['app.component.scss'],
  })
  
  export class AppComponent {
    constructor(
      private platform: Platform
    ) 
    {
      this.initializeApp();
    }
    
     initializeApp(){
        this.platform.ready().then(() => {
    
          const OnymosConnectObject={
            customerId : 'Your customerId goes here', 
            onymosAuthToken : 'Your onymosAuthToken goes here',  
            envType: 'PRD',
            version: '2'
            }
    
          OnymosInitialize.initialize(
            OnymosConnectObject,
          
            function onymosInitializeSuccess(status){
              console.log("Onymos initialized Successfully.", status)
            },
    
            function onymosInitializeFailure(error){
              console.log("Onymos failed to initialize.", error)
           })
         })
      }
    }
    

Great! If we configured your onymosConnectObject correctly, onymosInitializeSuccess() should print its message to the console. Now we’re ready to use Access.

Let’s integrate Apple, Facebook, and Google social sign-in with your app. We’ll start by creating a function called socialLogin() inside of your app.component.ts file. It will invoke the login() method, which will require an accessObj with a property called authProvider. We can use its value to identify which platform (“apple”, “facebook”, or “google”) you want to use to authenticate your user.

socialLogin(authProvider){
  let accessObj = {
	                authProvider: authProvider
		          }

  OnymosAccess.login(
    accessObj, 

  function onymosAccessLoginSuccess(data){
    console.log('A user logged in:', Date.now());
  }, 
		
  function onymosAccessLoginFailure (error){
    console.log(error);
  });

}

Since we’re passing an authProvider as an argument, let’s go to the app.component.html file and write the front-end code that will support socialLogin().

<div (click)="socialLogin('google')">
  <p> Sign in with Google </p>
</div>
  
<div (click)="socialLogin('apple')">
  <p> Sign in with Apple </p>
</div>

<div (click)="socialLogin('facebook')">
  <p> Sign in with Facebook </p>
</div>

Our click event will pass the authProvider the user chooses to socialLogin() and populate the value in the accessObj!

Now, your app can authenticate a user with Apple, Facebook, and Google. Try adding even more functionality with methods like getAuth() to protect one or more of your app’s pages from unauthorized users.

You can learn more about Access by checking out my “How Do I Add Social Login to an Ionic App?” post.

4. Troubleshooting

How do I squash this bug? Is Ionic supposed to do that? Why is this iOS build failing?

Let’s figure it out—join the Onymos community on Reddit! More of a loner? You can email us directly at customersuccess@onymos.com.

Dig into our API documentation

Developer support

Got questions? Our support team is here to help.

Think differently about app development

Download our free white paper today to learn how Onymos Features can maximize the value of your developer resources — and shave days or weeks off your schedule.

Get your free white paper