BN

Experience

150

0 Best Reply Awards

  • Member Since 4 Months Ago
  • 0 Lessons Completed
  • 0 Favorites

17th April, 2017

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

Thanks! @jekinney

I used the following to diagnose my mistakes and misunderstandings....

1.) I was successfully creating a token with the following code placed in src/illuminate/Foundation/Auth/AuthenticatesUsers/Authenticated

So After the user is logged in I am creating a token.

$token = $user->createToken('Token Name')->accessToken;

log::error($token);

2.) Upon login the table oauth_access_tokens is creating a record with a field "ID". I mistakenly thought the ID field was the token....IT IS NOT THE TOKEN.

3.) I logged the token to the error log. Then I took the token from the error log and plugged it into Postman....Shazam....it worked.

JeKinney...the man...thanks!

Followup question. Why isn't the token stored in one of the 6 tables that passport creates when I installed it and then ran the migrations? Do I need to manually store the token into the user field...???

OH...As I write out my thoughts...I think that the key and secret are encrypting and decrypting the ID field that is stored with the oauth_access_token table....Is that what is happening?

I am going to write my frontend app in React JS...So react will just need to store a cookie or something on the client to continually send over the token for access....is that correct?

Thanks,

Brent

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

ping @jekinney

16th April, 2017

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

when re-reading your comment above...

"The token is a huge string. Almost like an ssh key in length, not the tokens name."

I'm confident that I'm not using the right token....

c2896r694d3542c21aa36e21awe4f057f3a8c7d6dr341fb512809dr6d6c189f651a8cb37b7abed7977020r76

This is coming from the field {id} from the oauth_access_token field in my DB

I modified it by adding about 5 random characters....but as you see it's nowhere near the length of an SSH key.

What am I doing wrong?

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

I did create a simple CORS at this point, and registered it as a middleware in the middleware class in the kernel.php file. It did not solve the issue.

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

Also, previously you mention CORS....but I am not using CORS at this point as I'm only submitting POSTMAN and not consuming API from another domain yet.

Do I need to implement CORS at this point? Also, is there a package that you've used for CORS, or did you write your own?

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

Thank you for suggestions...

I am using the three headers now as you suggest and it still is not working.

I am using the oauth_personal_token/id column from the DB...I assume that this is the token that is being generated. Why isn't the column titled token instead of ID? Anyway, when I submit this token in Postman I get a 401 unauthenticated.

Also, when I login via the default login blade, it creates a remember_token in the Users DB table. This token also creates a 401 error.

Both tokens that are getting created are having 401 error code.

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

I wrote huge reply and got timed out and lost it....more frustration.

15th April, 2017

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

I've got some problems on my end I suppose then...

I've ensured that this isn't a problem:

https://github.com/laravel/passport/issues/47

I've created a oauth_access_token in my DB using

$token = $user->createToken('Token Name')->accessToken;

Then I'm using Postman to submit an API request:

Using: Authorization= "Bearer token" && Accept="application/json"

Every time I submit a request I get a 401.

My route is:

Route::get('/user/{user}', function (App\user $user) { return $user->email; })->middleware('auth:api');

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

It's noted frequently on these board that the code is buggy, the code isn't apparently implemented much as the bugs listed here are show stoppers in many respects.

The only conclusion I'm drawing is that I've followed the instructions and docs to the letter and nothing works.

So I continue to ask the question....is this code implementable....or too many bugs in it for production?

Is anybody using it in production environment?

While it may be overkill, it apparently should be able to work with a restful API.

BN left a reply on Laravel & Passport = Frustration And 401 • 4 months ago

ping

BN started a new conversation Laravel & Passport = Frustration And 401 • 4 months ago

I've spent days trying to configure Laravel/Passport and get nothing but 401 unauthenticated error codes.

Is this just a buggy part of the code and I should just spin my own JWT? I've seen a lot of errors and writings in this section and I'm tired of trying to figure this out.

Mindspace does a great tutorial on Laravel and setting up JWT on Youtube. He purposefully says he didn't use Passport, and I think he did that because the code isn't good. He didn't throw Laravel under the bus, but I will after days trying to configure it.

https://www.youtube.com/watch?v=5NchGeHv8GE&index=11&list=PL55RiY5tL51rrgq6xi67Mc6cwOHXw_nB1

Any suggestions?

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.