{"id":22085610,"url":"https://github.com/nexmo/vonage-dotnet-jwt","last_synced_at":"2025-04-09T20:23:02.866Z","repository":{"id":55663131,"uuid":"269115048","full_name":"Nexmo/vonage-dotnet-jwt","owner":"Nexmo","description":"Library providing jwt generation functionality for .NET users","archived":false,"fork":false,"pushed_at":"2025-03-19T18:39:11.000Z","size":43,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-03-23T22:15:55.564Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Nexmo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-03T14:48:09.000Z","updated_at":"2023-03-27T01:53:44.000Z","dependencies_parsed_at":"2025-01-29T05:34:37.461Z","dependency_job_id":null,"html_url":"https://github.com/Nexmo/vonage-dotnet-jwt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-dotnet-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-dotnet-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-dotnet-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Nexmo%2Fvonage-dotnet-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Nexmo","download_url":"https://codeload.github.com/Nexmo/vonage-dotnet-jwt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248104991,"owners_count":21048437,"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-01T01:15:18.874Z","updated_at":"2025-04-09T20:23:02.832Z","avatar_url":"https://github.com/Nexmo.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vonage Dotnet JWT\n\n\u003cimg src=\"https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg\" height=\"48px\" alt=\"Nexmo is now known as Vonage\" /\u003e\n\n## Welcome to Vonage\n\nIf you're new to Vonage, you can [sign up for a Vonage API account](https://dashboard.nexmo.com/sign-up?utm_source=DEV_REL\u0026utm_medium=github\u0026utm_campaign=vonage-dotnet-jwt) and get some free credit to get you started.\n\n## Overview\n\nThis library is designed to facilitate the generation of JWTs both for legacy Vonage API calls as well as more advanced use cases, such as conversations. For full docs on how JWTs are used in the Vonage APIs see our [documentation website](https://developer.nexmo.com/concepts/guides/authentication#json-web-tokens-jwt). To see slightly more advanced use cases with the Vonage Conversations API see [this article](https://developer.nexmo.com/conversation/guides/jwt-acl)\n\n## Generating JWTs\n\n### Create a Token with a Raw Private Key\n\nTo generate a JWT, or any number of JWTs given a set of parameters you must first initialize a `JwtGenerator`. You can do this by passing in your Vonage Application ID along with your application's private key into the `JwtGenerator` constructor, Subsequently, you can then generate a JWT using the generator's `GenerateJwt` method:\n\n```csharp\nvar generator = new Vonage.JwtGeneration.JwtGenerator(applicationId, privateKeyPath);\nvar jwt = generator.GenerateJwt();\n```\n\n### Change Expiration Time of Token\n\nEach token generated by the `JwtGenerator` will carry an `exp` claim set to 15 minutes after the time the token was generated. To change the 15 minutes timer, change the `JwtGenerator` `TokenTimeToLive` to the desired value in seconds (default is 900).\n\n### Generate a Token from a Private Key path\n\nThe JwtGenerator's constructor will accept either a raw private key or a file path, however if you are using a file path it is recommended that you use the `JwtGeneratorFactory.CreateGeneratorWithFilePathAsync` method to read the file asynchronously.\n\n```csharp\nvar generator = await JwtGeneratorFactory.CreateGeneratorWithFilePathAsync(applicationId, privateKeyPath);\nvar jwt = generator.GenerateJwt();\n```\n\n### Adding Acls to your tokens\n\nIf you are using the Vonage Conversations API or the Client SDK, you will need to add particular Acls to your tokens. The easiest way to do this is to add full permissions to each Token. This is the method shown [here](https://developer.nexmo.com/conversation/guides/jwt-acl#acls). This can be accomplished by making use of the third, optional argument in the `JwtGenerator` constructor, as well as the `Acls.FullAcls` method. \n\n```csharp\nvar generator = new JwtGenerator(applicationId, privateKey, Acls.FullAcls());\nvar jwt = generator.GenerateJwt();\n```\n\n### Specifying Acls in Your Tokens\n\nIf you do not wish to grant full permissions in your token, you can add permissions to whatever path you desire by adding each path individually to the `Acls` `Paths` list. This will take a set of `AclPath` objects, each of which contains an `ApiVersion`, `ResourceType`, `Resource`, and `AccessLevels`. A fully open Path has those values set to `*`, `resourceType e.g. users`, `**`, `{}` and the path will be formatted as `/ApiVersion/ResourceType/Resource\":AccessLevels`.\n\n```csharp\nvar acls = new Acls\n{\n    Paths = new List\u003cAclPath\u003e\n    {\n        new AclPath\n        {\n            ApiVersion = \"*\", ResourceType = \"users\", Resource = \"**\", AccessLevels = new object()\n        }\n    }\n};\nvar generator = new JwtGenerator(_mockAppId, _mockRsaPrivateKey, acls);\nvar jwt = generator.GenerateJwt();\n```\n\nThis will produce the path: `\"*/users/**\":{}` in the `acls` claim of your JWT\n\n## Getting Help\n\nWe love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:\n\n* Open an issue on this repository\n* Tweet at us! We're [@VonageDev on Twitter](https://twitter.com/VonageDev)\n* Or [join the Vonage Developer Community Slack](https://developer.nexmo.com/community/slack)\n\n## Further Reading\n\n* Check out the Developer Documentation at \u003chttps://developer.nexmo.com\u003e\n\n\u003c!-- add links to the api reference, other documentation, related blog posts, whatever someone who has read this far might find interesting :) --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo%2Fvonage-dotnet-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexmo%2Fvonage-dotnet-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo%2Fvonage-dotnet-jwt/lists"}