{"id":29182825,"url":"https://github.com/magiclabs/magic-admin-go","last_synced_at":"2025-07-01T20:33:09.013Z","repository":{"id":39858624,"uuid":"294224835","full_name":"magiclabs/magic-admin-go","owner":"magiclabs","description":"Magic admin Go SDK makes it easy to leverage Decentralized ID tokens to protect routes and restricted resources for your application.","archived":false,"fork":false,"pushed_at":"2023-09-06T20:06:13.000Z","size":121,"stargazers_count":21,"open_issues_count":4,"forks_count":10,"subscribers_count":19,"default_branch":"master","last_synced_at":"2024-06-18T18:47:59.630Z","etag":null,"topics":["authentication","go","golang","identity","passwordless"],"latest_commit_sha":null,"homepage":"https://docs.magic.link/admin-sdk/go","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/magiclabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-09T20:41:07.000Z","updated_at":"2024-03-12T12:46:40.000Z","dependencies_parsed_at":"2024-06-18T18:34:06.646Z","dependency_job_id":"9fb02d4b-dfa6-44fa-bc66-eaa10075872b","html_url":"https://github.com/magiclabs/magic-admin-go","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/magiclabs/magic-admin-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclabs%2Fmagic-admin-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclabs%2Fmagic-admin-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclabs%2Fmagic-admin-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclabs%2Fmagic-admin-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclabs","download_url":"https://codeload.github.com/magiclabs/magic-admin-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclabs%2Fmagic-admin-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263033222,"owners_count":23403117,"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":["authentication","go","golang","identity","passwordless"],"created_at":"2025-07-01T20:32:58.854Z","updated_at":"2025-07-01T20:33:08.900Z","avatar_url":"https://github.com/magiclabs.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Magic Admin Golang SDK\n\nThe Magic Admin Golang SDK provides convenient ways for developers to interact with Magic API endpoints and an array of utilities to handle [DID Token](https://magic.link/docs/introduction/decentralized-id).\n\n## Table of Contents\n\n* [Documentation](#documentation)\n* [Quick Start](#quick-start)\n* [Development](#development)\n* [Changelog](#changelog)\n* [License](#license)\n\n## Documentation\nSee the [Magic doc](https://magic.link/docs/api-reference/server-side-sdks/go)!\n\n## Installation\n\nThe SDK requires `Golang 1.13+` and Go Modules. To make sure your project is using Go Modules, you can look for `go.mod` file in your project's root directory. If it exits, then you are already using the Go Modules. If not, you can follow [this guide](https://blog.golang.org/migrating-to-go-modules) to migrate to Go Modules.\n\nSimply reference `magic-admin-go` in a Go program with an `import` of the SDK:\n\n``` golang\nimport (\n    ...\n    \"github.com/magiclabs/magic-admin-go\"\n    ...\n)\n```\n\nRun any of the normal `go` commands (ex: `build`/`install`). The Go toolchain will take care of fetching the SDK automatically.\n\nAlternatively, you can explicitly `go get` the package into a project:\n\n```sh\ngo get github.com/magiclabs/magic-admin-go\n```\n\n## Command line utility\n\nCommand line utility is created for testing purposes and can be used for decoding and validating DID tokens. It also provides functionality to retrieve user info.\n\nYou can simply install it by the command:\n```bash\ngo install github.com/magiclabs/magic-admin-go/cmd/magic-cli\n```\n\nCurrent available command supported:\n\n```bash\n$ magic-cli -h\nNAME:\n   magic-cli - command line utility to make requests to api and validate tokens\n\nUSAGE:\n   magic-cli [global options] command [command options] [arguments...]\n\nCOMMANDS:\n   token, t   magic-cli token [decode|validate] --did \u003cDID token\u003e [--clientId \u003cMagic Client ID\u003e]\n   user, u    magic-cli -s \u003csecret\u003e user --did \u003cDID token\u003e\n   help, h    Shows a list of commands or help for one command\n\nGLOBAL OPTIONS:\n   --secret value, -s value  Secret token which will be used for making request to backend api [$MAGIC_API_SECRET_KEY]\n   --help, -h                show help (default: false)\n```\n\n## Quick Start\n\nBefore you start, you will need an API secret key. You can get one from the [Magic Dashboard](https://dashboard.magic.link/). Once you have the API secret key, you can instantiate a Magic object.\n\nSample code to retrieve user info by a [DID token](https://docs.magic.link/decentralized-id):\n```golang\npackage main\n\nimport (\n    \"log\"\n    \"fmt\"\n\n    \"github.com/magiclabs/magic-admin-go\"\n    \"github.com/magiclabs/magic-admin-go/client\"\n)\n\nfunc main() {\n    m, err := client.New(\"\u003cYOUR_API_SECRET_KEY\u003e\", magic.NewDefaultClient())\n    userInfo, err := m.User.GetMetadataByToken(\"\u003cDID_TOKEN\u003e\")\n    if err != nil {\n        log.Fatalf(\"Error: %s\", err.Error())\n    }\n\n    fmt.Println(userInfo)\n}\n```\n\nSample code to validate a [DID token](https://docs.magic.link/decentralized-id) and retrieve the `claim` and `proof` from the token:\n```golang\npackage main\n\nimport (\n    \"log\"\n    \"fmt\"\n\n\t\"github.com/magiclabs/magic-admin-go/client\"\n    \"github.com/magiclabs/magic-admin-go/token\"\n)\n\nfunc main() {\n\n\tc, err := client.New(\"\u003cYOUR_API_SECRET_KEY\u003e\", magic.NewDefaultClient())\n\n\tif err != nil {\n\t\tlog.Fatalf(\"Unable to initialize client: %s\", err.Error())\n\t}\n\t\n\ttk, err := token.NewToken(\"\u003cDID_TOKEN\u003e\")\n    if err != nil {\n        log.Fatalf(\"DID token is malformed: %s\", err.Error())\n    }\n    \n    if err := tk.Validate(c.ClientInfo.ClientId); err != nil {\n        log.Fatalf(\"DID token is invalid: %v\", err)\n    }\n\n    fmt.Println(tk.GetClaim())\n    fmt.Println(tk.GetProof())\n}\n```\n\n### Configure Network Strategy\n\nThe `NewClientWithRetry` method creates a client with `retries`,  `retryWait`, `timeout` options. `NewClientWithRetry` returns a `*resty.Client` instance which can be used with the Magic client.\n\n```golang\ncl := magic.NewClientWithRetry(5, time.Second, 10 * time.Second)\nm := client.New(\"\u003cYOUR_API_SECRET_KEY\u003e\", cl)\n```\n\n## Development\n\nWe would love to have you contribute to the SDK. To get started, you will need to clone this repository and fetch the dependencies.\n\nTo run the existing tests:\n\n```bash\nmake test\n```\n\nTo build and install magic-cli utility tool, you can run:\n\n```bash\nmake install\n```\n\nTo build magic-cli utility tool separately as a binary, you can run:\n\n```bash\nmake build\n```\n\nPlease also see our [CONTRIBUTING](CONTRIBUTING.md) guide for more information.\n\n## Changelog\nSee [Changelog](CHANGELOG.md)\n\n## License\nSee [License](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclabs%2Fmagic-admin-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclabs%2Fmagic-admin-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclabs%2Fmagic-admin-go/lists"}