I'm trying to access the Google Analytics API from a VB.NET server application. My app falls into the category of a 'service account' application, so I'm not requesting credentials from the user--the app has its own credentials, which it uses to retrieve data from Google to show to the user.
The 13 size is also optional. If you leave it out, the compiler will count how many bytes are required for the string (including the NULL). This only works if you initialize the string like I have done.
The service-account OAuth2 workflow requires the application to generate a JWT (JSON Web Token) as a means of authenticating itself. I found a .NET library to generate these tokens, but I'm a little confused on which 'key' to give this library. In the library's documentation, the example key given is a base-64-looking string of numbers and uppercase and lowercase letters. But what I have is a
.p12
private-key file and the corresponding password. How can I extract some kind of textual key from this key file?I tried to do something like
but this leaves me with a byte array, not a string. Am I on the right track here?
bdeshambdesham
1 Answer
I believe I've figured out what to do:
As @Jim Mischel pointed out, I just needed to encode the key data in base-64.
By the way, adding the
X509KeyStorageFlags.Exportable
flag fixed a CryptographicException (“Key not valid for use in specified state.”) while trying to export the key.bdeshambdesham