diff --git a/.changeset/brave-shoes-push.md b/.changeset/brave-shoes-push.md new file mode 100644 index 0000000000..3c6a8d7e0e --- /dev/null +++ b/.changeset/brave-shoes-push.md @@ -0,0 +1,40 @@ +--- +'@backstage/create-app': patch +--- + +Added the default `ScmAuth` implementation to the app. + +To apply this change to an existing app, head to `packages/app/apis.ts`, import `ScmAuth` from `@backstage/integration-react`, and add a `ScmAuth.createDefaultApiFactory()` to your list of APIs: + +```diff + import { + ScmIntegrationsApi, + scmIntegrationsApiRef, ++ ScmAuth, + } from '@backstage/integration-react'; + + export const apis: AnyApiFactory[] = [ +... ++ ScmAuth.createDefaultApiFactory(), +... + ]; +``` + +If you have integrations towards SCM providers other than the default ones (github.com, gitlab.com, etc.), you will want to create a custom `ScmAuth` factory instead, for example like this: + +```ts +createApiFactory({ + api: scmAuthApiRef, + deps: { + gheAuthApi: gheAuthApiRef, + githubAuthApi: githubAuthApiRef, + }, + factory: ({ githubAuthApi, gheAuthApi }) => + ScmAuth.merge( + ScmAuth.forGithub(githubAuthApi), + ScmAuth.forGithub(gheAuthApi, { + host: 'ghe.example.com', + }), + ), +}); +``` diff --git a/packages/app/src/apis.ts b/packages/app/src/apis.ts index 08ff781319..d587a88402 100644 --- a/packages/app/src/apis.ts +++ b/packages/app/src/apis.ts @@ -17,6 +17,7 @@ import { ScmIntegrationsApi, scmIntegrationsApiRef, + ScmAuth, } from '@backstage/integration-react'; import { costInsightsApiRef, @@ -41,6 +42,8 @@ export const apis: AnyApiFactory[] = [ factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi), }), + ScmAuth.createDefaultApiFactory(), + createApiFactory({ api: graphQlBrowseApiRef, deps: { errorApi: errorApiRef, githubAuthApi: githubAuthApiRef }, diff --git a/packages/create-app/templates/default-app/packages/app/src/apis.ts b/packages/create-app/templates/default-app/packages/app/src/apis.ts index f2cd272c87..c89753aae8 100644 --- a/packages/create-app/templates/default-app/packages/app/src/apis.ts +++ b/packages/create-app/templates/default-app/packages/app/src/apis.ts @@ -1,6 +1,7 @@ import { ScmIntegrationsApi, scmIntegrationsApiRef, + ScmAuth, } from '@backstage/integration-react'; import { AnyApiFactory, @@ -14,4 +15,5 @@ export const apis: AnyApiFactory[] = [ deps: { configApi: configApiRef }, factory: ({ configApi }) => ScmIntegrationsApi.fromConfig(configApi), }), + ScmAuth.createDefaultApiFactory(), ];