Back to Puter

Auth

src/docs/src/Auth.md

26.06.13.0 KB
Original Source

The Authentication API enables users to authenticate with your application using their Puter account.

This is essential for users to access the various Puter.js APIs integrated into your application. The auth API supports several features, including sign-in, sign-out, checking authentication status, and retrieving user information.

Features

<div style="overflow:hidden; margin-bottom: 30px;"> <div class="example-group active" data-section="sign-in"><span>Sign In</span></div> <div class="example-group" data-section="is-signed-in"><span>Check Sign In</span></div> <div class="example-group" data-section="get-user"><span>Get User</span></div> <div class="example-group" data-section="sign-out"><span>Sign Out</span></div> </div> <div class="example-content" data-section="sign-in" style="display:block;">

Initiates the sign in process for the user

html;auth-sign-in
</div> <div class="example-content" data-section="is-signed-in">

Checks whether the user is signed into the application

html;auth-is-signed-in
<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.print(`Sign in status: ${puter.auth.isSignedIn()}`);
    </script>
</body>
</html>
</div> <div class="example-content" data-section="get-user">

Returns the user's basic information

html;auth-get-user
<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.auth.getUser().then(function(user) {
            puter.print(JSON.stringify(user));
        });
    </script>
</body>
</html>
</div> <div class="example-content" data-section="sign-out">

Signs the user out of the application

html;auth-sign-out
<html>
<body>
    <script src="https://js.puter.com/v2/"></script>
    <script>
        puter.auth.signOut();
    </script>
</body>
</html>
</div>

Functions

These authentication features are supported out of the box when using Puter.js:

Examples

You can see various Puter.js authentication features in action from the following examples: