MCPcopy Create free account
hub / github.com/bytebase/bytebase / getTeamsAppID

Method getTeamsAppID

backend/plugin/webhook/teams/app.go:284–307  ·  view source on GitHub ↗

getTeamsAppID retrieves the Teams app ID from the app catalog. The app must be published to the organization's app catalog.

(ctx context.Context)

Source from the content-addressed store, hash-verified

282// getTeamsAppID retrieves the Teams app ID from the app catalog.
283// The app must be published to the organization's app catalog.
284func (p *provider) getTeamsAppID(ctx context.Context) (string, error) {
285 // The externalId in the app catalog is the same as the clientID (Azure AD app ID).
286 apiURL := fmt.Sprintf("https://graph.microsoft.com/v1.0/appCatalogs/teamsApps?$filter=externalId%%20eq%%20'%s'", p.clientID)
287
288 b, err := p.doGraphRequest(ctx, http.MethodGet, apiURL, nil)
289 if err != nil {
290 return "", errors.Wrapf(err, "failed to query app catalog")
291 }
292
293 var resp struct {
294 Value []struct {
295 ID string `json:"id"`
296 } `json:"value"`
297 }
298 if err := json.Unmarshal(b, &resp); err != nil {
299 return "", errors.Wrapf(err, "failed to unmarshal app catalog response")
300 }
301
302 if len(resp.Value) == 0 {
303 return "", errors.Errorf("Teams app with externalId %s not found in app catalog", p.clientID)
304 }
305
306 return resp.Value[0].ID, nil
307}
308
309// ensureAppInstalledForUser ensures the Teams app is installed for a user.
310// Returns the installation ID.

Callers 1

sendMessageMethod · 0.95

Calls 3

doGraphRequestMethod · 0.95
UnmarshalMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected