I've been working on integrating a Google OAuth login feature. Once the user successfully logs in with their Google account, a JWT token is sent to this endpoint on my Express server, where it is then decoded using jsonwebtoken:
app.post('/login/google', express.urlencoded(), async(request, response, next) => {
try {
console.log(`${request.method} ${request.url} was called.`);
let token: string = request.body.credential;
let decoded = jwt.verify(token, Globals.GoogleSecret, { algorithms: ['RS256'], ignoreExpiration: false });
response.sendStatus(200);
}
catch (error) {
next(error);
}
});
The decoded token
extracted from the request body appears valid (I even checked it on jwt.io).
The error being caught states:
code: 'ERR_OSSL_PEM_NO_START_LINE'
function: 'get_name'
library: 'PEM routines'
reason: 'no start line'
message: 'error:0909006C:PEM routines:get_name:no start line'
Can someone provide insight into what might be causing this issue and how to resolve it?
Some additional information for clarity:
Globals.GoogleSecret
is a string set as the Client secret value found under my OAuth 2.0 Client ID Credential in the API Console.- I have an Angular web app accessible at http://localhost:4200/.
- This app sends the Google OAuth credentials to the Express server using
.data-login_uri="http://localhost:1337/login/google"
- The development environment is Windows-based, coding done in VSCode.