🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@netsells/nuxtjs-client-secret

Package Overview
Dependencies
Maintainers
9
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netsells/nuxtjs-client-secret

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

latest
npmnpm
Version
1.0.6
Version published
Weekly downloads
11
450%
Maintainers
9
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 26 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts