Miss any of our Open RFC calls?Watch the recordings here! »

keycred

1.0.0 • Public • Published

A key credential generator for Office 365 API App-Only Permissions (Client Credentials Grant Flow) in Azure AD.

Introduction

This utility can be used to generate the keyCredentials that allows for "app-only" access to the Office 365 API from within Azure AD applications.

When setting up a new application within Azure, it provides an Application Manifest that can be used to provide key credentials for your application to access the API. Many of the online tutorials provide a walkthrough on how to generate the keys for this, but not from a cross-platform way.

This utility provides an easy-to-use cross-platform way to generate a keyCredentials that can be used to populate the application manifest file.

Instructions

First thing you must do is install the library using Node.js NPM.

npm install -g keycred

Next, simply run the application by typing the following...

keycred

Follow the instructions it provides.

Example

prompt: Would you like to generate a new Certificate or use an existing one?

  1.) Generate New
  2.) Use Existing:  1
prompt: Country Name (2 letter code) [AU]:  US
prompt: State or Province Name (full name) [Some-State]:  Texas
prompt: Locality Name (eg, city) []:  Dallas
prompt: Organization Name (eg, company) [Internet Widgits Pty Ltd]:  Form.io
prompt: Organizational Unit Name (eg, section) []:  IT
prompt: Common Name (e.g. server FQDN or YOUR name):  Travis Tidwell
prompt: Number of years until expiration (default is 1, max is 30):  3
Generating key pairs
Creating a certificate.
Signing the certificate.

Key Credentials:
{
    "customKeyIdentifier": "abrvf2N5nwK5Lkqfkku5xstfkWI=",
    "value": "MIID1TCCAr2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBmMRcwFQYDVQQDEw5UcmF2aXMgVGlkd2VsbDELMAkGA1UEBhMCVVMxDjAMBgNVBAgTBVRleGFzMQ8wDQYDVQQHEwZEYWxsYXMxEDAOBgNVBAoTB0Zvcm0uaW8xCzAJBgNVBAsTAklUMB4XDTE1MDgwNzE2MzQwNFoXDTE2MDgwNzE2MzQwNFowZjEXMBUGA1UEAxMOVHJhdmlzIFRpZHdlbGwxCzAJBgNVBAYTAlVTMQ4wDAYDVQQIEwVUZXhhczEPMA0GA1UEBxMGRGFsbGFzMRAwDgYDVQQKEwdGb3JtLmlvMQswCQYDVQQLEwJJVDCCASIwDQYJKoZIhvcN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hKBiUxZ
tZpalqeWKTkhB7tFs5lWepgzZ/JTsKwkCtCZp2D6UJ7+HbfqQ/jOBlFXITbtsOLi
GFQI0WTgtHPg9Bj2kZin4UjNpOdvE0qK7XFCiPkyAUGvGHqetq2dw1Z9rxQ5w03Z
ZIL1DTVNtN3mxC8PX5Bcc0IOcsSNLqcXDt43+amTMYBMWbYYFOYjqZVEdIXf+ZzO
JzjwXoFL53RYxKHdZXWC8y4f6dd0jzwNIvepnx7SDa8CAwEAAaOBjTCBijAMBgNV
HRMEBTADAQH/MAsGA1UdDwQEAwIC9DA7BgNVHSUENDAyBggrBgEFBQcDAQYIKwYB
BQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDBAYIKwYBBQUHAwgwEQYJYIZIAYb4QgEB
BAQDAgD3MB0GA1UdDgQWBBSFghpkrNaarwWD5lyvy1ll95iU+DANBgkqhkiG9w0B
AQUFAAOCAQEArl/lxpD9lRuRPiaWgIipECkxZv3bOyaS/x1I23H21w1t7w5aNac6
PxvJhvA0qehNqT/nYGmopCYBDEv7nLGWIwZNUKAcIXGmNZWoOkH9d8RP45h3Mb0a
nWd8t/WuJr/Q3Jby5UvKeVKec2ews2wr8qm+AeONF1KwWUe7pyQN5G4bwbOTrFeO
4Epf/Q9jxnN8xH7Jx5hSkVOQGOKa8vB80QKewKAeF3XcEqFTiLpvulmwiBiUAEVp
jJ2FEw3+3QygSBkbzFdz6F8w644AL7ep0TpSXHDh07hEugsMx6xOCAD6e40pLCkT
2y4UDAoeHovhD3jD7dUEuv5UyWiTu3esLw==
-----END CERTIFICATE-----

Once you have the keyCredential generated, you can then add that your your manifest file as follows...

55e1a764-58c7-4423-a75e-75b902e22cce.json*

...
...
  "keyCredentials": [
    {
        "customKeyIdentifier": "abrvf2N5nwK5Lkqfkku5xstfkWI=",
        "value": "MIID1TCCAr2gAwIBAgIBATANBgkqhkiG9w0BAQUFADBmMRcwFQYDVQQDEw5UcmF2aXMgVGlkd2VsbDELMAkGA1UEBhMCVVMx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O4Epf/Q9jxnN8xH7Jx5hSkVOQGOKa8vB80QKewKAeF3XcEqFTiLpvulmwiBiUAEVpjJ2FEw3+3QygSBkbzFdz6F8w644AL7ep0TpSXHDh07hEugsMx6xOCAD6e40pLCkT2y4UDAoeHovhD3jD7dUEuv5UyWiTu3esLw==",
        "keyId": "f1f70508-8ec6-42b0-9bdc-5e0514e7cc4b",
        "usage": "Verify",
        "type": "AsymmetricX509Cert"
    }
  ],
...
...

The private and public keys can then be used within your application to access the API's.

Enjoy...

Keywords

none

Install

npm i keycred

DownloadsWeekly Downloads

11

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar