Eray Bartan
Eray Bartan Blog

Eray Bartan Blog

Use JWT Token connect Google Auth on NextJS

Use JWT Token connect Google Auth on NextJS

you don't need Credentials Json File

Eray Bartan's photo
Eray Bartan

Published on Aug 20, 2021

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Couldn't connect using the google credentials file. Provided the link with the following codes without using JSON.

const jwt = new google.auth.JWT(
      process.env.GOOGLE_SHEETS_CLIENT_EMAIL,
      null,
      process.env.GOOGLE_SHEETS_PRIVATE_KEY.replace(/\\n/g, '\n'),
      scopes
    );

    const sheets = google.sheets({ version: "v4", auth: jwt });

GOOGLE_SHEETS_PRIVATE_KEY

There is an important detail for the GOOGLE_SHEETS_PRIVATE_KEY environment variable. please add "\n" as character at start

"\n-----BEGIN PRIVATE KEY-----\nxxxxxxxxxxxx=\n-----END PRIVATE KEY-----\n"
 
Share this

Impressum

Technical Specialties

  • React Native App Development
  • Neo4j Graph Database Beginner Developer
  • Google Data Studio Dashboard Design
  • Micosoft Power BI Dashboard Design

Industry Experience

  • Municiapilty (IT Department, Data Analyst)
  • Real Estate (Web Design, Social Media Publisher, Mailchimp Automation)
  • Hotels & Restaurants (Web Design, Google Ads , Facebook Ads)
  • Sports (Web Design, Mailchimp Campaign)
Proudly part of