Code Monkey home page Code Monkey logo

php-jwt-authentication-example's Introduction

PHP JWT Authentication Example

This is a simple example application that implements JWT Authentication. It exposes three endpoints

  • api/login.php
  • api/register.php
  • api/protected.php

For detailed steps check out this tutorial.

How to Run This App

First clone the repo:

$ git clone https://github.com/techiediaries/php-jwt-authentication-example.git

Next, navigate inside the project's folder and run the following command to start the server:

$ cd php-jwt-authentication-example
$ composer install
$ php -S 127.0.0.1:8000

php-jwt-authentication-example's People

Contributors

techiediaries avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-jwt-authentication-example's Issues

Uncaught ArgumentCountError: Too few arguments to function Firebase

Hi. thanks for the git and the tutorial. I Followed the instructions closely. I can register users. However I get a 500 error here: http://test.lan/php-jwt-example/api/login.php

{ "email": "[email protected]", "password": "1234567" }

PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function Firebase\\JWT\\JWT::encode(), 2 passed in /test/public_html/php-jwt-example/api/login.php on line 65 and at least 3 expected in /test/public_html/php-jwt-example/vendor/firebase/php-jwt/src/JWT.php:183

Stack trace:#0 /test/public_html/php-jwt-example/api/login.php(65): Firebase\\JWT\\JWT::encode() #1 {main} thrown in /test/public_html/php-jwt-example/vendor/firebase/php-jwt/src/JWT.php on line 183

here is line 65:
$jwt = JWT::encode($token, $secret_key);

It works with this: $jwt = JWT::encode($payload, $key, 'HS256');
Taken from here: https://github.com/firebase/php-jwt
I suspect the jwt argument requirements have changed since this was written.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.