PagerDuty / backstage-plugin

PagerDuty plugin for Backstage
https://pagerduty.github.io/backstage-plugin-docs/index.html
Apache License 2.0
21 stars 5 forks source link

OAuth Authentication for PagerDuty Fails with "Missing or Invalid PagerDuty Token" Error #104

Open RP-flaviojunior opened 2 weeks ago

RP-flaviojunior commented 2 weeks ago

Describe the bug The OAuth authentication method for PagerDuty is not working. When attempting to authenticate, the following error messages are logged:

[1] 2024-06-12T13:45:55.611Z pagerduty warn No PagerDuty API token found in config file. Trying OAuth token instead...
[1] 2024-06-12T13:45:56.512Z rootHttpRouter info ::1 - - [12/Jun/2024:13:45:56 +0000] "POST /api/permission/authorize HTTP/1.1" 200 74 "-" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" type=incomingRequest
[1] 2024-06-12T13:45:56.513Z rootHttpRouter info ::1 - - [12/Jun/2024:13:45:56 +0000] "POST /api/catalog/entities/by-refs/ HTTP/1.1" 200 822 "http://localhost:3000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36" type=incomingRequest
[1] 2024-06-12T13:45:56.582Z pagerduty error Unable to retrieve valid PagerDuty AUTH configuration from config file: Error: Failed to retrieve valid token. Bad Request - Invalid arguments provided.

In the console, the following message appears:

Missing or invalid PagerDuty Token

To Reproduce Steps to reproduce the behavior:

  1. Configure the Backstage app with the following app-config.yaml settings:
    pagerDuty:
    oauth:
    clientId: ${PD_CLIENT_ID}
    clientSecret: ${PD_CLIENT_SECRET}
    subDomain: ${PD_ACCOUNT_SUBDOMAIN}
    region: ${PD_ACCOUNT_REGION}
  2. Start the Backstage application.
  3. Attempt to authenticate with PagerDuty using OAuth.
  4. Observe the error messages in the logs and console.

Expected behavior The OAuth authentication should successfully retrieve a valid token and authenticate with PagerDuty without errors.

Screenshots If applicable, add screenshots to help explain your problem. Screenshot 2024-06-12 at 10 57 30

Desktop (please complete the following information):

Additional context The issue appears to be related to the inability to retrieve a valid token from PagerDuty using the provided OAuth credentials.

t1agob commented 1 week ago

Hello @RP-flaviojunior! Thanks for reporting this and congrats on opening your first issue with us.

I've been trying to reproduce this error but I'm unable to. Can you double check if the environment variables you are passing to your app-config.yaml file are actually present and correct? Thanks in advance!