简体   繁体   English

验证令牌ID并使用PHP访问令牌

[英]Verify token ID and access token with PHP

How can I use the OPENID with PHP, without using libs? 如何在不使用lib的情况下将OPENID与PHP一起使用?

I was using the Twitch OAuth2.0 and after building the authentication I get the "id_token" and an "access_token". 我使用的是Twitch OAuth2.0,在建立身份验证之后,我得到了“ id_token”和“ access_token”。

How do I validate the id_token and the access_token using PHP to get a code? 如何使用PHP验证id_token和access_token以获取代码?

ID Token is a kind of JWT . ID令牌是一种JWT JWT is a kind of either JWS or JWE . JWT是JWSJWE的一种。 The following are relevant specifications. 以下是相关规格。

If you want to validate ID tokens without using libraries, as the first step, you have to understand the specifications. 如果要在不使用库的情况下验证ID令牌,则第一步,您必须了解规范。 Then, do all the stuff like decoding, decrypting and verifying signatures using PHP standard functions. 然后,使用PHP标准功能完成所有工作,例如解码,解密和验证签名。

NOTE: Regardless of whether ID Token is encrypted or not, a signature is attached. 注意:无论ID令牌是否已加密,都将附加一个签名。 To verify the signature, if the algorithm of the signature is asymmetric, you have to get the public key which corresponds to the private key used for the signature. 要验证签名,如果签名的算法是非对称的,则必须获取与用于签名的私钥相对应的公钥。

On the other hand, the format of access tokens varies depending on implementations. 另一方面, 访问令牌的格式取决于实现方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM