1.0.6 • Published 5 years ago

@netsells/nuxtjs-client-secret v1.0.6

Weekly downloads
10
License
ISC
Repository
-
Last release
5 years ago

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

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago