{"id":23698062,"url":"https://github.com/inloco/incognia-go","last_synced_at":"2026-04-22T22:02:17.336Z","repository":{"id":40401995,"uuid":"409280945","full_name":"inloco/incognia-go","owner":"inloco","description":"Go library for Incognia API","archived":false,"fork":false,"pushed_at":"2024-11-06T22:28:41.000Z","size":141,"stargazers_count":5,"open_issues_count":5,"forks_count":5,"subscribers_count":18,"default_branch":"main","last_synced_at":"2024-11-06T23:25:41.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inloco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-22T16:38:16.000Z","updated_at":"2024-11-06T22:28:44.000Z","dependencies_parsed_at":"2023-11-10T18:25:11.909Z","dependency_job_id":"9c43cabe-bba3-418d-b9ba-f1c317d94633","html_url":"https://github.com/inloco/incognia-go","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloco%2Fincognia-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloco%2Fincognia-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloco%2Fincognia-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inloco%2Fincognia-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inloco","download_url":"https://codeload.github.com/inloco/incognia-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231823690,"owners_count":18431949,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-30T07:13:28.603Z","updated_at":"2026-04-22T22:02:17.325Z","avatar_url":"https://github.com/inloco.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Incognia API Go Client\n\n![test workflow](https://github.com/inloco/incognia-go/actions/workflows/continuous.yml/badge.svg)\n\nGo lightweight client library for [Incognia APIs](https://dash.incognia.com/api-reference).\n\n## Installation\n\n```\ngo get repo.incognia.com/go/incognia\n```\n\n## Usage\n\n### Configuration\n\nFirst, you need to obtain an instance of the API client using `New`. It receives a configuration\nobject of `IncogniaClientConfig` that contains the following parameters:\n\n| Parameter             | Description                                    | Required | Default       |\n| --------------------- | ---------------------------------------------- | -------- | ------------- |\n| `ClientID`            | Your client ID                                 | **Yes**  | -             |\n| `ClientSecret`        | Your client secret                             | **Yes**  | -             |\n| `Timeout`             | Request timeout                                | **No**   | 10 seconds    |\n| `HTTPClient`          | Custom HTTP client                             | **No**   | `http.Client` |\n\nFor instance, if you need the default client:\n\n```go\nclient, err := incognia.New(\u0026incognia.IncogniaClientConfig{\n    ClientID:     \"your-client-id\",\n    ClientSecret: \"your-client-secret\",\n})\nif err != nil {\n    log.Fatal(\"could not initialize Incognia client\")\n}\n```\n\nor if you need a client that uses a specific timeout:\n\n```go\nclient, err := incognia.New(\u0026incognia.IncogniaClientConfig{\n    ClientID:     \"your-client-id\",\n    ClientSecret: \"your-client-secret\",\n    Timeout:      time.Second * 2,\n})\nif err != nil {\n    log.Fatal(\"could not initialize Incognia client\")\n}\n```\n\nor if you need a custom HTTP client:\n\n```go\ntransport := http.DefaultTransport.(*http.Transport).Clone()\ntransport.MaxIdleConns = 1000\ntransport.MaxIdleConnsPerHost = 100\ntransport.MaxConnsPerHost = 200\n\nhttpClient := \u0026http.Client{\n    Timeout:   time.Second * 2,\n    Transport: transport,\n}\n\nclient, err := incognia.New(\u0026incognia.IncogniaClientConfig{\n    ClientID:     \"your-client-id\",\n    ClientSecret: \"your-client-secret\",\n    Timeout:      time.Second * 2,\n    HTTPClient:   httpClient,\n})\nif err != nil {\n    log.Fatal(\"could not initialize Incognia client\")\n}\n```\n\n### Incognia API\n\nThe implementation is based on the [Incognia API Reference](https://dash.incognia.com/api-reference).\n\n### Authentication\n\nAuthentication is done transparently, so you don't need to worry about it.\n\n### Registering Signup\n\nThis method registers a new signup for the given installation and address, returning a `SignupAssessment`, containing the risk assessment and supporting evidence:\n\n```go\nassessment, err := client.RegisterSignup(\"installation-id\", \u0026incognia.Address{\n    AddressLine: \"20 W 34th St, New York, NY 10001, United States\",\n    StructuredAddress: \u0026incognia.StructuredAddress{\n        Locale:       \"en-US\",\n        CountryName:  \"United States of America\",\n        CountryCode:  \"US\",\n        State:        \"NY\",\n        City:         \"New York City\",\n        Borough:      \"Manhattan\",\n        Neighborhood: \"Midtown\",\n        Street:       \"W 34th St.\",\n        Number:       \"20\",\n        Complements:  \"Floor 2\",\n        PostalCode:   \"10001\",\n    },\n    Coordinates: \u0026incognia.Coordinates{\n        Lat: -23.561414,\n        Lng: -46.6558819,\n    },\n})\n```\n\nTo provide additional parameters like policy id (optional) and account id (optional), use the `RegisterSignupWithParams` method:\n\n```go\nassessment, err := client.RegisterSignupWithParams(\u0026incognia.Signup{\n\tInstallationID: \"installation-id\",//required\n\tAddress: \u0026incognia.Address{//optional, use nil if you don't have an address\n        AddressLine: \"20 W 34th St, New York, NY 10001, United States\",\n        StructuredAddress: \u0026incognia.StructuredAddress{\n            Locale:       \"en-US\",\n            CountryName:  \"United States of America\",\n            CountryCode:  \"US\",\n            State:        \"NY\",\n            City:         \"New York City\",\n            Borough:      \"Manhattan\",\n            Neighborhood: \"Midtown\",\n            Street:       \"W 34th St.\",\n            Number:       \"20\",\n            Complements:  \"Floor 2\",\n            PostalCode:   \"10001\",\n        },\n        Coordinates: \u0026incognia.Coordinates{\n            Lat: -23.561414,\n            Lng: -46.6558819,\n        },\n    },\n    AccountID: \"account-id\",//optional, use empty string if you don't have an account id\n    PolicyID:  \"policy-id\",//optional, use empty string if you don't have a policy id\n})\n```\n\n### Registering Payment\n\nThis method registers a new payment for the given installation and account, returning a `TransactionAssessment`, containing the risk assessment and supporting evidence.\n\n```go\nassessment, err := client.RegisterPayment(\u0026incognia.Payment{\n    InstallationID: \"installation-id\",\n    AccountID:      \"account-id\",\n    ExternalID:     \"external-id\",\n    PolicyID:       \"policy-id\",\n    Coupon:         \u0026incognia.CouponType{\n        Type:        \"coupon-type\", //it should be percent_off or fixed_value\n        Value:       55.02,\n        MaxDiscount: 30,\n        Id:          \"identifier\",\n        Name:        \"coupon-name\",\n    },\n    CustomProperties: myCustomPropertiesMap\n    Addresses: []*incognia.TransactionAddress{\n        {\n            Type: incognia.Billing,\n            AddressLine:    \"20 W 34th St, New York, NY 10001, United States\",\n            StructuredAddress: \u0026incognia.StructuredAddress{\n                Locale:       \"en-US\",\n                CountryName:  \"United States of America\",\n                CountryCode:  \"US\",\n                State:        \"NY\",\n                City:         \"New York City\",\n                Borough:      \"Manhattan\",\n                Neighborhood: \"Midtown\",\n                Street:       \"W 34th St.\",\n                Number:       \"20\",\n                Complements:  \"Floor 2\",\n                PostalCode:   \"10001\",\n            },\n            Coordinates: \u0026incognia.Coordinates{\n                Lat: -23.561414,\n                Lng: -46.6558819,\n            },\n        },\n    },\n    Value: \u0026incognia.PaymentValue{\n        Amount:   55.02,\n        Currency: \"BRL\",\n    },\n    Methods: []*incognia.PaymentMethod{\n        {\n\t    Type: incognia.GooglePay,\n\t},\n        {\n            Type: incognia.CreditCard,\n            CreditCard: \u0026incognia.CardInfo{\n                Bin:            \"292821\",\n                LastFourDigits: \"2222\",\n                ExpiryYear:     \"2020\",\n                ExpiryMonth:    \"10\",\n            },\n        },\n    },\n})\n```\n\nThis method registers a new **web** payment for the given installation and account, returning a `TransactionAssessment`, containing the risk assessment and supporting evidence.\n\n```go\nassessment, err := client.RegisterPayment(\u0026incognia.Payment{\n    RequestToken:   \"request-token\",\n    AccountID:      \"account-id\",\n    ExternalID:     \"external-id\",\n    PolicyID:       \"policy-id\",\n    ...\n})\n```\n\n\n### Registering Login\n\nThis method registers a new login for the given installation and account, returning a `TransactionAssessment`, containing the risk assessment and supporting evidence.\n\n```go\nassessment, err := client.RegisterLogin(\u0026incognia.Login{\n    InstallationID:             \"installation-id\",\n    AccountID:                  \"account-id\",\n    ExternalID:                 \"external-id\",\n    PolicyID:                   \"policy-id\",\n    PaymentMethodIdentifier:    \"payment-method-identifier\",\n    CustomProperties: myCustomPropertiesMap,\n})\n```\n\nThis method registers a new **web** login for the given account and request-token, returning a `TransactionAssessment`, containing the risk assessment and supporting evidence.\n\n```go\nassessment, err := client.RegisterLogin(\u0026incognia.Login{\n    RequestToken:               \"request-token\",\n    AccountID:                  \"account-id\",\n    ...\n})\n```\n\n### Registering Payment or Login without evaluating its risk assessment\n\nTurning off the risk assessment evaluation allows you to register a new transaction (Login or Payment), but the response (`TransactionAssessment`) will be empty. For instance, if you're using the risk assessment only for some payment transactions, you should still register all the other ones: this will avoid any bias on the risk assessment computation.\n\nTo register a login or a payment without evaluating its risk assessment, you should use the `Eval *bool` attribute as follows:\n\nLogin example:\n\n```go\nshouldEval := false\n\nassessment, err := client.RegisterLogin(\u0026incognia.Login{\n    Eval:           \u0026shouldEval,\n    InstallationID: \"installation-id\",\n    AccountID:      \"account-id\",\n    ExternalID:     \"external-id\",\n    PolicyID:       \"policy-id\",\n})\n```\n\nPayment example:\n\n```go\nshouldEval := false\n\nassessment, err := client.RegisterPayment(\u0026incognia.Payment{\n    Eval:            \u0026shouldEval,\n    InstallationID: \"installation-id\",\n    AccountID:      \"account-id\",\n    ExternalID:     \"external-id\",\n    PolicyID:       \"policy-id\",\n    Addresses: []*incognia.TransactionAddress{\n        {\n            Type: incognia.Billing,\n            AddressLine:    \"20 W 34th St, New York, NY 10001, United States\",\n            StructuredAddress: \u0026incognia.StructuredAddress{\n                Locale:       \"en-US\",\n                CountryName:  \"United States of America\",\n    ...\n```\n\n### Sending Feedback\n\nThis method registers a feedback event for the given identifiers (represented in `FeedbackIdentifiers`) related to a signup, login or payment.\n\n```go\noccurredAt, err := time.Parse(time.RFC3339, \"2024-07-22T15:20:00Z\")\nfeedbackEvent := incognia.AccountTakeover\nerr := client.RegisterFeedback(feedbackEvent, \u0026occurredAt, \u0026incognia.FeedbackIdentifiers{\n    InstallationID: \"some-installation-id\",\n    AccountID:      \"some-account-id\",\n})\n```\n\n### Authentication\n\nOur library manages authentication automatically, including refreshing expired tokens. By default, token refresh happens synchronously during an API call. This means that if the token has expired, the request will take longer to complete—especially because the token endpoint intentionally has higher latency to mitigate brute-force attacks.\n\nFor latency-sensitive services, you can take control of when token refresh occurs by using `ManualRefreshTokenProvider`. This allows you to refresh tokens proactively (e.g., in the background), avoiding delays during critical requests.\n\nThe example below demonstrates how to periodically refresh the token in a separate thread:\n\n```go\ntokenClient := incognia.NewTokenClient(\u0026TokenClientConfig{ClientID: clientID, ClientSecret: clientSecret})\ntokenProvider := incognia.NewManualRefreshTokenProvider(tokenClient)\nc, err := incognia.New(\u0026IncogniaClientConfig{ClientID: clientID, ClientSecret: clientSecret, TokenProvider: tokenProvider})\nif err != nil {\n    log.Fatal(\"could not initialize Incognia client\", err)\n}\n\ngo func(i *incognia.Client) {\n  for {\n      accessToken, err := tokenProvider.Refresh()\n      log.Println(\"token refreshed, expires at \" + accessToken.GetExpiresAt().String())\n      if (err != nil) {\n          log.Println(\"could not refresh token\")\n          continue\n      }\n      time.Sleep(time.Until(accessToken.GetExpiresAt()))\n   }\n}(c)\n```\n\nYou can also keep the default automatic authentication but increase the token route timeout by changing the `TokenRouteTimeout` parameter of your `IncogniaClientConfig`.\n\n## Evidences\n\nEvery assessment response (`TransactionAssessment` and `SignupAssessment`) includes supporting evidence in the type `Evidence`, which provides methods `GetEvidence` and `GetEvidenceAsInt64` to help you getting and parsing values. You can see usage examples below:\n\n```go\nvar deviceModel string\n\nerr := assessment.Evidence.GetEvidence(\"device_model\", \u0026deviceModel)\nif err != nil {\n    return err\n}\n\nfmt.Println(deviceModel)\n```\n\nYou can also access specific evidences using their full path. For example, to get `location_permission_enabled` evidence from the following response:\n\n```json\n{\n    \"evidence\": {\n        \"location_services\": {\n            \"location_permission_enabled\": true\n        }\n    }\n}\n```\n\ncall any type of `GetEvidence` method using the evidence's full path:\n\n```go\nvar locationPermissionEnabled bool\nerr := assessment.Evidence.GetEvidence(\"location_services.location_permission_enabled\", \u0026locationPermissionEnabled)\nif err != nil {\n    return err\n}\n\nfmt.Println(locationPermissionEnabled)\n```\n\nYou can find all available evidence [here](https://developer.incognia.com/docs/apis/v2/understanding-assessment-evidence).\n\n## How to Contribute\n\nIf you have found a bug or if you have a feature request, please report them at this repository issues section.\n\n## What is Incognia?\n\nIncognia is a location identity platform for mobile apps that enables:\n\n- Real-time address verification for onboarding\n- Frictionless authentication\n- Real-time transaction verification\n\n## License\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finloco%2Fincognia-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finloco%2Fincognia-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finloco%2Fincognia-go/lists"}