Can not connect to github api with forge

I’m new in cloud dev with forge.

I want to get some informations from github api but i’m not able to.

i configured my povider and my github oauth app but i get the following error :slight_smile:
{
“message”: “Authentication required”,
“name”: “NEEDS_AUTHENTICATION_ERR”,
“stack”: “”
}

Please can someone help me, i’m blocked in it for days now

1 Like

Hi @AchrafMECHTA,
Welcome to the community :smiley:
Please share your manifest file.

Regards
Magdalena Lidia Rogulska

1 Like

modules:
jira:issuePanel:
- key: afd2salesforce-hello-world-panel
function: main
title: Made by Achraf
icon: link
function:
- key: main
handler: index.run
provider:
auth:
- github
app:
id: ari:cloud:ecosystem::app/c23d7eb2-3456-407e-a386-0d2fa357dd1d
providers:
auth:

- key: github
  name: github
  clientId: 005c02792a09bd054e38
  bearerMethod: authorization-header
  type: oauth2
  remotes:
        - google-apis
  actions:
    authorization:
      remote: google-account
      path: /
    exchange:
      remote: google-oauth
      path: /
    retrieveProfile:
      remote: google-apis
      path: /contents
      resolvers:
        id: id
        displayName: email
        avatarUrl: picture

remotes:

  • key: google-apis
    baseUrl: api github link
  • key: google-account
    baseUrl: api github link
  • key: google-oauth
    baseUrl: api github link

permissions:
scopes:
- read:jira-work
- write:jira-work
external:
fetch:
backend:
- ‘https://www.api.github.com’ => api github link
- ‘https://www.github.com

i appreciate your help

There are few things you might check:

  1. The path might not be / please check if you follow every step of Forge OAuth documentation.
  2. You might need queryParameters added like in example:
authorization:
          remote: google-account
          path: /somePath/oauth2/v2.0/authorize
          queryParameters: { response_mode: 'query' }

Also, please provide a traceId from the request going to https://id.atlassian.com/outboundAuth/finish if those two things will not work.

Regards
Magdalena Lidia Rogulska

1 Like

I followed all the the steps of the given , i even create a seprate project with the same files ( external auth = google) and i have the same issue.

for the second link i get this error : RequestValidationError: Schema validation error

excuse my comprehension i’m just a beginner

1 Like

Trace ID: b27fd038f9f1580e
There was an error invoking the function - Authentication required

1 Like

i’m really glad if you can help me

1 Like

any updates please

1 Like

Hi @AchrafMECHTA,
I passed your question further so please be patient - we will try to help you :slight_smile:

Regards
Magdalena Lidia Rogulska

1 Like

Hi @MagdalenaRogulska ,

Thank you

Regards

1 Like

Hi,
One more question - are you sure that all needed data is provided and there is no null or undefined value instead of it and that data is provided in the right time (async functions may lead to race condition)?

Regards

1 Like

Hi @AchrafMECHTA,

I have created an app with github as provider with the below manifest, can you try with the sample below and see if you are able to pull the details of user?

remotes:
  - key: github-oauth
    baseUrl: https://github.com
  - key: github-user
    baseUrl: https://api.github.com
modules:
  macro:
    - key: github-external-auth
      function: main
      title: github-external-auth
      description: github-external-auth
  function:
    - key: main
      handler: index.run
      providers:
        auth:
          - github
app:
  id: <app-id>
permissions:
  scopes: []
  external:
    fetch:
      backend:
        - https://github.com
        - https://api.github.com
providers:
  auth:
    - key: github
      name: Github
      scopes:
        - read:user
        - public_repo
      type: oauth2
      bearerMethod:
        type: authorization-header
      clientId:<client_ID>
      remotes:
        - github-oauth
        - github-user
      actions:
        authorization:
          remote: github-oauth
          path: /login/oauth/authorize
          queryParameters:
            response_type: code
        exchange:
          remote: github-oauth
          path: /login/oauth/access_token
          resolvers:
            accessToken: access_token
        revokeToken:
          remote: github-oauth
          path: /login/oauth/access_token
        retrieveProfile:
          remote: github-user
          path: /user
          resolvers:
            id: id
            displayName: login
            avatarUrl: avatar_url

Another question : Have you run setup the client credentials using the forge configure command?

1 Like

Hello @Ash

it worked for me, thank you so much.

many thanks to @MagdalenaRogulska also.

Regards