Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bearer token Authorization support #353

Merged
merged 1 commit into from
Aug 26, 2022

Conversation

parallels999
Copy link
Contributor

@parallels999 parallels999 commented Aug 26, 2022

Closes #352
Tested, this PR does not affect current functionality, also works with third party jwt tokens

When making requests using API tokens, the token should be included in the Authorization header as a Bearer token.
When the mobile application uses the token to make an API request to your application, it should pass the token in the Authorization header as a Bearer token. "Laravel Sanctum"

Broadcast::routes(["middleware" => ['auth:api',/*'auth:sanctum',*/]]);

Current:

var TOKEN='*******';
{
  // csrfToken: '******'
  auth: {
      headers: {
          Authorization: "Bearer " + TOKEN
      },
  },
  userAuthentication: {
      headers: {
          Authorization: "Bearer " + TOKEN
      },
  },
}

New(Shorter):

{
  // csrfToken: '******'
  bearerToken: '*******',
}

Sources:
https://laravel.com/docs/9.x/sanctum#issuing-api-tokens
PR: [9.x] User authentication for Pusher framework#42531
signin() method: https://pusher.com/docs/channels/using_channels/user-authentication/#sign-in
#189 (comment)
#26 (comment)
#26 (comment)
#26 (comment)
#26 (comment)
#282 (comment)
#219 (comment)

> npm run compile && npm run declarations
> laravel-echo@1.[13](https://github.com/laravel/echo/runs/8038132230?check_suite_focus=true#step:6:14).1 compile
> ./node_modules/.bin/rollup -c
./src/echo.ts → ./dist/echo.js, ./dist/echo.common.js...
(!) Mixing named and default exports
https://rollupjs.org/guide/en/#outputexports
The following entry modules are using named and default exports together:
src/echo.ts

Consumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use `output.exports: 'named'` to disable this warning
created ./dist/echo.js, ./dist/echo.common.js in 4.5s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bearer Token Authentication Configuration
2 participants