public static function dirtyDecode($access_token, $claims = [])
    {
        $now = time();
        $expecting = false;
        $incorrect = false;
        $expired = false;
        $error = false;
        $errors = array();
        $decodedToken = array();
        $token_segments = explode('.', $access_token);
        $body = (isset($token_segments[1])) ? $token_segments[1] : null;

        if (count($token_segments) != 3) {
            $error = true;
            $errors[] = "Token has wrong number of segments";
        }
        if (null === $data = static::jsonDecode(static::urlDecode($body))) {
            $error = true;
            $errors[] = "Decoder has problem with Token encoding";
        }
        if (isset($data->nbf) && $data->nbf > $now) {
            $expecting = true;
        }
        if (isset($data->iat) && $data->iat > $now) {
            $incorrect = true;
        }
        if (isset($data->exp) && $now >= $data->exp) {
            $expired = true;
        }

        $decodedToken =  array(
            'token_id' => (isset($data->jti)) ? $data->jti : null,
            'user_id' => (isset($data->sub)) ? $data->sub : null,
            'expecting' => $expecting,
            'start_at_unix' => (isset($data->nbf)) ? $data->nbf : null,
            'start_at' => (isset($data->nbf)) ? date(DateTime::ISO8601, $data->nbf) : null,
            'incorrect' => $incorrect,
            'created_at_unix' => (isset($data->iat)) ? $data->iat : null,
            'created_at' => (isset($data->iat)) ? date(DateTime::ISO8601, $data->iat) : null,
            'expired' => $expired,
            'expires_at_unix' => (isset($data->exp)) ? $data->exp : null,
            'expires_at' => (isset($data->exp)) ? date(DateTime::ISO8601, $data->exp) : null,
            'error' => $error,
            'errors' => $errors,
            'valid' => ($expecting || $incorrect || $expired || $error) ? false : true
        );

        if(!empty($claims)){
            $decodedToken['claims'] = static::getCustomClaims($data, $claims);
        }

        return $decodedToken;
    }
public static function dirtyDecode($access_token, $claims = [])
    {
        $now = time();
        $expecting = false;
        $incorrect = false;
        $expired = false;
        $error = false;
        $errors = array();
        $decodedToken = array();
        $token_segments = explode('.', $access_token);
        $body = (isset($token_segments[1])) ? $token_segments[1] : null;

        if (count($token_segments) != 3) {
            $error = true;
            $errors[] = "Token has wrong number of segments";
        }
        if (null === $data = static::jsonDecode(static::urlDecode($body))) {
            $error = true;
            $errors[] = "Decoder has problem with Token encoding";
        }
        if (isset($data->nbf) && $data->nbf > $now) {
            $expecting = true;
        }
        if (isset($data->iat) && $data->iat > $now) {
            $incorrect = true;
        }
        if (isset($data->exp) && $now >= $data->exp) {
            $expired = true;
        }

        $decodedToken =  array(
            'token_id' => (isset($data->jti)) ? $data->jti : null,
            'user_id' => (isset($data->sub)) ? $data->sub : null,
            'expecting' => $expecting,
            'start_at_unix' => (isset($data->nbf)) ? $data->nbf : null,
            'start_at' => (isset($data->nbf)) ? date(DateTime::ISO8601, $data->nbf) : null,
            'incorrect' => $incorrect,
            'created_at_unix' => (isset($data->iat)) ? $data->iat : null,
            'created_at' => (isset($data->iat)) ? date(DateTime::ISO8601, $data->iat) : null,
            'expired' => $expired,
            'expires_at_unix' => (isset($data->exp)) ? $data->exp : null,
            'expires_at' => (isset($data->exp)) ? date(DateTime::ISO8601, $data->exp) : null,
            'error' => $error,
            'errors' => $errors,
            'valid' => ($expecting || $incorrect || $expired || $error) ? false : true
        );

        if(!empty($claims)){
            $decodedToken['claims'] = static::getCustomClaims($data, $claims);
        }

        return $decodedToken;
    }
public static function dirtyDecode ( $ access_token , $ claims = [ ] ) { $ now = time ( ) ; $ expecting = false ; $ incorrect = false ; $ expired = false ; $ error = false ; $ errors = array ( ) ; $ decodedToken = array ( ) ; $ token_segments = explode ( '.' , $ access_token ) ; $ body = ( isset ( $ token_segments [ 1 ] ) ) ? $ token_segments [ 1 ] : null ; if ( count ( $ token_segments ) != 3 ) { $ error = true ; $ errors [ ] = "Token has wrong number of segments" ; } if ( null === $ data = static :: jsonDecode ( static :: urlDecode ( $ body ) ) ) { $ error = true ; $ errors [ ] = "Decoder has problem with Token encoding" ; } if ( isset ( $ data -> nbf ) && $ data -> nbf > $ now ) { $ expecting = true ; } if ( isset ( $ data -> iat ) && $ data -> iat > $ now ) { $ incorrect = true ; } if ( isset ( $ data -> exp ) && $ now >= $ data -> exp ) { $ expired = true ; } $ decodedToken = array ( 'token_id' => ( isset ( $ data -> jti ) ) ? $ data -> jti : null , 'user_id' => ( isset ( $ data -> sub ) ) ? $ data -> sub : null , 'expecting' => $ expecting , 'start_at_unix' => ( isset ( $ data -> nbf ) ) ? $ data -> nbf : null , 'start_at' => ( isset ( $ data -> nbf ) ) ? date ( DateTime :: ISO8601 , $ data -> nbf ) : null , 'incorrect' => $ incorrect , 'created_at_unix' => ( isset ( $ data -> iat ) ) ? $ data -> iat : null , 'created_at' => ( isset ( $ data -> iat ) ) ? date ( DateTime :: ISO8601 , $ data -> iat ) : null , 'expired' => $ expired , 'expires_at_unix' => ( isset ( $ data -> exp ) ) ? $ data -> exp : null , 'expires_at' => ( isset ( $ data -> exp ) ) ? date ( DateTime :: ISO8601 , $ data -> exp ) : null , 'error' => $ error , 'errors' => $ errors , 'valid' => ( $ expecting || $ incorrect || $ expired || $ error ) ? false : true ) ; if ( ! empty ( $ claims ) ) { $ decodedToken [ 'claims' ] = static :: getCustomClaims ( $ data , $ claims ) ; } return $ decodedToken ; }
Decode a Access Token

@param string $access_token Access Token

@return array
Decode a Access Token