Start Building

LastPass Developer Documentation

Show/hide navigation

Sample Codes – Auth

Configuration

Before using the authentication API you must set up the config.properties file with the appropriate key values.

  • Open the config.properties file with a text editor. This file is located under AuthAPI/java-auth/src/test/resources/config.properties for java samples, AuthAPI/python-auth/config.properties for python, and AuthAPI/nodejs-auth/config.properties for NodeJS samples.
  • Log into the LastPass Admin Portal and open the “Advanced Options” tab on the left side menu. Select “Keys” from the submenu, and copy the LastPass MFA Login key value.

  • Then set mfa_key and generic_api_key properties in your config.properties file.

Java

Java 1.8 samples can be found in AuthAPI/java-auth folder. AuthenticationSample.java test class shows how to authenticate with LastPass. Before testing you need to set USERNAME attribute to your user’s email. Then go to main mehtod and check the available authentication modes: plain or encrypted, synchronous or asynchronous.

Compile the project with maven and then execute the tests. You can user your favorite IDE too.

Python

Python 3 samples can be found in AuthAPI/python-auth folder. AuthenticationSample.py script shows how to authenticate with LastPass through HTTPS protocol. Execute the authentication script from a command line:

NodeJS

NodeJS samples can be found in AuthAPI/nodejs-auth folder. The main.js script shows how to authenticate with LastPass through HTTPS protocol. Edit the main.js script and change the user name located at line 10 in main.js.

Save changes and then install and execute the script. Once executed, an authentication request will be sent to LastPass authentication service and a push notification will appear in the smartphone afterwards.

References

Github repositories

Authentication – https://github.com/lastpasspublic/AuthAPI.

Copyright@2020LogMeIn, Inc. All Rights Reserved