Novices Plagiarizing Mozart
Have ideas to improve npm?Join in the discussion! »

@netsells/nuxtjs-client-secret

1.0.6 • Public • Published

nuxtjs-client-secret

Middleware for getting an access token from your API for your frontend without exposing your client ID and secret

Installation

yarn add @netsells/nuxtjs-client-secret

Usage

In your nuxtjs config:

    modules: [
        ['@netsells/nuxtjs-client-secret', {
            token_url: process.env.TOKEN_API_URL,
            grant_type: 'client_credentials',
            client_id: process.env.API_PERSONAL_ACCESS_CLIENT_ID,
            client_secret: process.env.API_PERSONAL_ACCESS_CLIENT_SECRET,
        }],
    ],

You should set your client secrets in your .env file, not your nuxtjs config file.

This will set a cookie, access_token, with the access token returned by your API.

You can then add the necessary authorization headers to your front end requests, e.g. for axios:

import axios from 'axios';
import { getAuthHeaders } from '@netsells/nuxtjs-client-secret';
 
axios.defaults.headers.common = getAuthHeaders();

Keywords

none

Install

npm i @netsells/nuxtjs-client-secret

DownloadsWeekly Downloads

11

Version

1.0.6

License

ISC

Unpacked Size

6.24 kB

Total Files

6

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar