I've looked online for information on SecKeys and even more on what I'm trying to do, with little result. All I'm wanting to do is access the Google API for a Google calendar from my iOS app. I've read through Google's documentation on how to authenticate using OAuth2. I've obtained a private key for my service account, and I have an API key already, an app identity, etc. I know I've got to submit a JWT to Google's token server in exchange for a token. I've got the header and payload encoded to base64. The only part I'm stuck on is the last part, creating the signature. I know I need to generate a JWS, but documentation on doing this is sparse. To help, I've employed the use of JOSESwift from GitHub (https://github.com/airsidemobile/JOSESwift. The first thing it wants is to define a variable as a SecKey.
let privateKey: SecKey = /* ... */But the documentation doesn't tell me what /* ... */ is supposed to be. I was assuming it was my private key, so I tried to feed it as a string value, but that failed. Then I tried encoding the private key as base64 and setting that as the secKey but that also failed. I tried casting my private key as Data and passing that, but it also failed. Online documentation and prior answers to this problem are so sparse and I've not been able to find a solution, so I'm turning here for help. What do I need in order to create a SecKey in Swift?