by Overwolf
  • Nitro
  • Publishers
    PUBLISHERS
    How it Works Documentation Newsletter
  • Advertisers
    ADVERTISERS
    Advertisers Offering Top Sites
  • Resources
    RESOURCES
    Ad Unit Demos Blog & News Press Releases FAQ Case Studies
  • NitroDex
Log in

Ad Publishers

  • Helpful Integration Tools and Common Issues
  • Google MCM – What is it?
  • Installing the ad script on your page
  • Setting up your ads.txt file
  • Creating an ad placement
  • Special Ad Formats
  • Detecting ad-blocking users
  • Creating a Playlist and Adding Content

Data and Privacy

  • Passing Hashed Emails
  • Creating a link for the user to manage their consents
  • US Privacy law compliance steps
  • Support for Google Analytics and Consent Mode
  • Adding custom consents or disclosures

Dashboard and Best Practices

  • Ad Layout Best Practices
  • Nitro Glossary
  • NitroPay
  • Docs
  • Managing user sessions

Managing user sessions

After a user successfully logs in through the authorization flow, the dialog will close and session information will be posted back and stored in local storage (configurable). You can now retrieve metadata about the user and perform the UI updates needed to accommodate their membership.

In JavaScript if you want to pull the information on the currently logged in user, you could write:

users.currentUser().then(function (user) {
    // Access to User entity now available
});

If you’re using modules, you may prefer to make a class to manage sessions. A complete example of instantiating the client and performing the most basic API commands is available here:

import { Auth } from '@nitropay/sdk/src/auth';
import { User, UsersClient } from '@nitropay/sdk/src/users';

export class SessionService {
    auth: Auth;
    currentUser: User;
    users: UsersClient;

    constructor() {
        this.auth = new Auth({ clientId: 'YourClientId', scope: 'openid offline' });
        this.users = new UsersClient(this.auth);
    }

    async load(): Promise<void> {
        this.currentUser = await this.users.currentUser();
    }

    async login(): Promise<void> {
        await this.auth.authorize();
        await this.load();
    }

    async logout(): Promise<void> {
        await this.auth.logout();
        this.currentUser = null;
    }
}

What are your Feelings
Share This Article :
  • Facebook
  • Twitter
  • LinkedIn
  • Pinterest
Updated on January 25, 2023
We use cookies to improve your experience and increase the relevancy of content when using Nitro. Our cookies are used for analytics, optimization, and advertising operations. Learn more.Got it
  • Publishers

    • How it works
    • Documentation
    • Newsletter
  • Advertisers

    • Advertisers Offering
    • Top Sites
  • Resources

    • Ad Unit Demos
    • Blog & News
    • Press Releases
    • FAQ
    • Case Studies
  • Companions

    • Overwolf
    • CurseForge
    • Tebex
  • Nitrodex

© Overwolf. All rights reserved.
  • Terms of Service
  • Privacy Policy