I followed the instructions here to get the access token for the web API.
https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx
It works for me, but the documentation is fuzzy when it comes to figuring out how to check the token in PHP.
You can use the access token that is returned in the response for authentication to secure resources, such as the web API. Typically, a token is represented by a web API in an HTTP request using the Bearer scheme described in RFC 6750. This specification explains how to use media tokens in HTTP requests to access protected resources.
When the web API receives and validates the token, it gives the available client application access to the web API.
How to check JWT in application? I have a PHP framework that uses the openssl_verify () PHP function with a marker, signal, key and algorithm, but I get an error when I use Azure's private key with the SHA256 algorithm:
openssl_verify(): supplied key param cannot be coerced into a public key
This makes me think that the key that I use in PHP for verification is incorrect. At the moment I am using the private key that I generated for the Active Directory application, which is also the same value that I use for the client_secret parameter when hitting the oauth2 / token URL (any other value does not cause the token generated, so that this is probably correct).
The key is similar to (BUT NOT DIRECTLY):
cLDQWERTYUI12asdqwezxctlkjpoiAn7yhjeutl8jsP=
When I believe, openssl should have a certificate ... if so, I cannot find where this certificate is located on the Azure portal.
What am I missing here? What key should I use with openssl_verify () to test JWT and where to find it in Azure?
thanks
-
UPDATE:
I found the public keys here: https://login.windows.net/common/discovery/keys
However, I still cannot use the X5C to verify the signature. How do you do this in PHP?
-
UPDATE 2:
I used the conversion to create a .pem file for the public key using the "e" and "n" options. This got the public key.
Now I get OPEN SSL errors when decrypting with it:
error:0906D06C:PEM routines:PEM_read_bio:no start line