I am trying to create a GitHub App in Golang by using a library named ghinstallation. As the description showed below, Integration ID and Installation ID are required.
// Wrap the shared transport for use with the integration ID 1 authenticating with installation ID 99.
itr, err := ghinstallation.NewKeyFromFile(tr, 1, 99, "2016-10-19.private-key.pem")
if err != nil {
log.Fatal(err)
}
I think the Installation ID is exactly the ID appears in the URL(https://github.com/settings/installations/:installation_id).
However, I've no idea what the Integration ID is.
The GitHub App Integration ID is the ID of your GitHub App. You can find it in the "About" section in the "General" tab of your GitHub App.
Related
I'm trying to setup the storage emulator for my firebase project. I am using the Go admin sdk. However it seems to be ignored despite following the documented process.
App initialization:
func App(ctx context.Context) (*firebase.App, error) {
opt := option.WithCredentialsFile("firebase-service-account.json")
config := firebase.Config{
StorageBucket: "<my-project-id>.appspot.com",
}
app, err := firebase.NewApp(ctx, &config, opt)
if err != nil {
return nil, fmt.Errorf("error initializing app: %v", err)
}
return app, nil
}
.env file loaded on startup:
FIRESTORE_EMULATOR_HOST="localhost:8081"
FIREBASE_STORAGE_EMULATOR_HOST="localhost:9199"
GCLOUD_PROJECT="my-project-id"
I also tried manually setting these by running:
export FIREBASE_STORAGE_EMULATOR_HOST="localhost:9199" and export GCLOUD_PROJECT="my-project-id".
However, when when writing to the default bucket, my blob appears in the actual firestore console for storage, not the storage emulator.
I pulled the GCLOUD_PROJECT value from my service account json file, the project_id field specifically. Also confirmed that 9199 is the port that storage is running on.
Besides setting those FIREBASE_STORAGE_EMULATOR_HOST and GCLOUD_PROJECT am I missing something else?
The variable name is STORAGE_EMULATOR_HOST.
See: https://pkg.go.dev/cloud.google.com/go/storage
Firebaser Here,
You're correct in that your current setup should have been sufficient. I've filed an issue in the GO SDK Repo so that this can get addressed.
In the meanwhile the current fix, as #mabg pointed out, is to set the STORAGE_EMULATOR_HOST variable as well Code Sample
I'm new to firebase and I'm trying to setup a small test with a simple database in Go.
I struggle a lot with the database connection. Here is my code:
tx := context.Background()
conf := &firebase.Config{
DatabaseURL: "https://mydb.europe-west1.firebasedatabase.app",
}
// Fetch the service account key JSON file contents
opt := option.WithCredentialsFile("./fireBasePrivateKey.json")
// Initialize the app with a service account, granting admin privileges
app, err := firebase.NewApp(ctx, conf, opt)
if err != nil {
log.Fatalln("Error initializing app:", err)
}
client, err := app.Database(ctx)
if err != nil {
log.Fatalln("Error initializing database client:", err)
}
With that code (which comes from the official documentation), I've got an error on the Database client initialization:
invalid database url: wants host: .firebaseio.com
I then tried with the requested url: mydb.firebaseio.com -> I've got another error telling me my db is not in that region and gives me the previous db address.
I also tried other things like mydb.europe-west1.firebaseio.com but here it says me the certificate is not valid for this url...
I'm a bit lost. I understand the problem has to do with the localization of the DB I choose when I created it, but I don't understand how to handle it with the go implementation.
The <projectname>.firebaseio.com format used to be the only format for Firebase Database URLs until early last year. Nowadays, databases in the US still use that format, but databases in other regions use the <dbname><region>.firebasedatabase.app format that you have.
Support for the newer URL format was added in PR #423 and released in version 4.6 of the Go Admin SDK, which was released in June. Upgrade to this version (or later), to ensure you don't get the error message anymore.
I used to set up a Fabric network and deployed a fabric network and basic application using a Fabric and Fabric GoLang SDK. I'm able to do the query and write to the chain.
Is there any way to retrieve the Block Info? Like block height and current hash?
+ I'm unable to find out a documentation for GoLang Fabric SDK.
I followed following code and tutorial,
Fabric Basic App - Tutorial
https://chainhero.io/2017/07/tutorial-build-blockchain-app/
Fabric Basic App using GoLang SDK - Code
https://github.com/chainHero/heroes-service/
GoLang SDK - Official SDK
https://github.com/hyperledger/fabric-sdk-go
In general, the sdk will provide the basic method such you said GetBlockInfo,I have search for the GoLang SDK, it can not be found. While Java sdk provide this such method reference this java test .
Another way to use these method(you must know a little fabric source code), in fact these method are included in the system chaincode, you could invoke the system chancode just like you invoke the normal chaincode.
A example is following:
from the go sdk test ,you could see this,
response, err := chClient.Query(chclient.Request{ChaincodeID: ccID, Fcn: "invoke", Args: integration.ExampleCCQueryArgs()})
just change the params
response, err := chClient.Query(chclient.Request{ChaincodeID: "qscc", Fcn: "invoke", Args: integration.ExampleCCQueryArgs("GetChainInfo")})
qscc is a system chancode,you could download the fabric source code,and from qscc file,you could see(it provide many invoke service):
GetChainInfo string = "GetChainInfo"
GetBlockByNumber string = "GetBlockByNumber"
GetBlockByHash string = "GetBlockByHash"
GetTransactionByID string = "GetTransactionByID"
GetBlockByTxID string = "GetBlockByTxID"
Go sdk(fabric-sdk-go/pkg/client/ledger) provides several methods for getting information about blockchain. For example:
...
client, err := ledger.New(channelContext)
block, err := client.QueryBlockByHash(blockHash)
block, err = client.QueryBlock(blockNumber)
The Go SDK now includes methods for querying block information. These methods are contained within the ledger client package.
You can see an example in the ledger client integration test.
I want to send a system notifications to windows using golang.
How can this be done?
if you awnser contains a cross platform solution it would be even better.
Finding system notification with Golang in 2020 and found this: https://github.com/gen2brain/beeep . It looks like currently still actively maintained.
Example from repo:
err := beeep.Notify("Title", "Message body", "assets/information.png")
if err != nil {
panic(err)
}
Even it works great, actually I feel that this app was made mainly for producing "beep" sound on the computer speaker. Based on the app name which is "beeep" :). You can check on example page if interest in makes those "beep" sound too.
I'm assuming you are looking for desktop notifications. There are a few different libraries that can do this for you. Originally I found this with a simple Google search
Link / Dependency URL: github.com/0xAX/notificator
Here is the example on their README.md page:
package main
import (
"github.com/0xAX/notificator"
)
var notify *notificator.Notificator
func main() {
notify = notificator.New(notificator.Options{
DefaultIcon: "icon/default.png",
AppName: "My test App",
})
notify.Push("title", "text", "/home/user/icon.png", notificator.UR_CRITICAL)
}
I have an app that needs to include a links to a second app in the same phone.
If the app is not installed the link should point to the windows store to install it (that part is working fine).
But if the app is already installed the link should go straight to the app and open it. How can I do that?
The app has two versions one form WP7 and other from WP8. if the solution is different for them please point the difference.
Thanks for the help...
I believe a URI Association is what you want. You should be able to create a different association in your WP7 app and in your WP8 app, and handle them accordingly.
A URI association allows your app to automatically launch when another app launches a special URI.
Also note:
If you are interested only in launching your own apps, consider using
APIs from the Windows.Phone.Management.Deployment namespace. You can
use this API to check for other apps that you’ve published, and then
launch them if they’re installed.
You basically just need to update the WMAppManifest.xml file to include the URI Association and then listen for that URI. Example:
<Extensions>
<Protocol Name="contoso" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
</Extensions>
Then you can use a custom URI Mapper to handle your association (full example in top link above):
public override Uri MapUri(Uri uri)
{
tempUri = System.Net.HttpUtility.UrlDecode(uri.ToString());
// URI association launch for contoso.
if (tempUri.Contains("contoso:ShowProducts?CategoryID="))
{
// Get the category ID (after "CategoryID=").
int categoryIdIndex = tempUri.IndexOf("CategoryID=") + 11;
string categoryId = tempUri.Substring(categoryIdIndex);
// Map the show products request to ShowProducts.xaml
return new Uri("/ShowProducts.xaml?CategoryID=" + categoryId, UriKind.Relative);
}
// Otherwise perform normal launch.
return uri;
}
Hope this helps!
Is the secondary app one that you have created? If so, do something like this:
IEnumerable<Package> packages = InstallationManager.FindPackagesForCurrentPublisher();
foreach (Package package in packages)
{
if (package.Id.ProductId.ToString().ToLower() == "product id of secondary app")
{
//Launch the app
package.Launch();
}
}
Make sure that your publisher ids match in the WMAppManifest for both apps.
If this secondary app was published by someone else, you'll need to use a custom Uri schema. The app needs to have this feature added by the developer, you can't just launch any app.