Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 2.98 KB

File metadata and controls

92 lines (66 loc) · 2.98 KB

Authentication - Check JSON Web Token (JWT)

Checks a user is authenticated and authorised.

Introduction

This endpoint is a simple endpoint that requires a user to be authenticated and so is a good endpoint to check a user is authenticated or to perform authentication as a side effect.

Enphase-API is an unofficial project providing an API wrapper and the documentation for Enphase®'s products and services.

More details on the project are available from the project’s homepage.

Details

This simple endpoint is configured to require any authentication.

It simply invokes the standard system wide authentication check.

If the authentication fails the user is met with a Authorization Required error. Should it succeed then the user will be diverted to the hidden endpoint /valid_token which just returns static text.

As JWT validation is more intensive it is preferred to use this end-point to create a session and then for all subsequent API requests (of varying resource intensity) to just use the sessionId cookie to authenticate.

Request

A HTTP GET to the /auth/check_jwt endpoint provides the following response data.

As of recent Gateway software versions this request requires user authentication and authorisation, see Authentication.

Examples

Check Authenticated (Success)

GET /auth/check_jwt Response
<!DOCTYPE html><h2>Valid token.</h2>

Check Authenticated (Failure)

GET /auth/check_jwt Response
<html>
<head><title>401 Authorization Required</title></head>
<body>
<center><h1>401 Authorization Required</h1></center>
<hr><center>Redirecting to <a id='link' href=''></a></center>
<script>
const redirect_url = window.location.protocol + '//' + window.location.host + '/home';
function redirect() { window.location.href = redirect_url; }
window.onload = function() {
    const link = document.getElementById('link');
    link.href = redirect_url;
    link.text = redirect_url;
    setTimeout(redirect, 500);
}
</script>
</body>
</html>