@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();

Readme

Keywords

none

Package Sidebar

Install

npm i @netsells/nuxtjs-client-secret

Weekly Downloads

0

Version

1.0.6

License

ISC

Unpacked Size

6.24 kB

Total Files

6

Last publish

Collaborators

  • rebeccaanderton
  • samturrell
  • spamoom
  • jakub.gawron