github.com/google/go-github/v33@v33.0.0/github/apps_manifest.go (about) 1 // Copyright 2019 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "context" 10 "fmt" 11 ) 12 13 const ( 14 mediaTypeAppManifestPreview = "application/vnd.github.fury-preview+json" 15 ) 16 17 // AppConfig describes the configuration of a GitHub App. 18 type AppConfig struct { 19 ID *int64 `json:"id,omitempty"` 20 NodeID *string `json:"node_id,omitempty"` 21 Owner *User `json:"owner,omitempty"` 22 Name *string `json:"name,omitempty"` 23 Description *string `json:"description,omitempty"` 24 ExternalURL *string `json:"external_url,omitempty"` 25 HTMLURL *string `json:"html_url,omitempty"` 26 CreatedAt *Timestamp `json:"created_at,omitempty"` 27 UpdatedAt *Timestamp `json:"updated_at,omitempty"` 28 ClientID *string `json:"client_id,omitempty"` 29 ClientSecret *string `json:"client_secret,omitempty"` 30 WebhookSecret *string `json:"webhook_secret,omitempty"` 31 PEM *string `json:"pem,omitempty"` 32 } 33 34 // CompleteAppManifest completes the App manifest handshake flow for the given 35 // code. 36 // 37 // GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/#create-a-github-app-from-a-manifest 38 func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) { 39 u := fmt.Sprintf("app-manifests/%s/conversions", code) 40 req, err := s.client.NewRequest("POST", u, nil) 41 if err != nil { 42 return nil, nil, err 43 } 44 req.Header.Set("Accept", mediaTypeAppManifestPreview) 45 46 cfg := new(AppConfig) 47 resp, err := s.client.Do(ctx, req, cfg) 48 if err != nil { 49 return nil, resp, err 50 } 51 52 return cfg, resp, nil 53 }