@netsells/nuxtjs-client-secret
Middleware for getting an access token from your API for your frontend without exposing your client ID and secret
Last updated a year ago by sam.boylett .
ISC · Original npm · Tarball · package.json
$ cnpm install @netsells/nuxtjs-client-secret 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.6                                ...           latest (a year ago)

7 Versions

  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (3)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |