jwt 和 weebly oAuth
jwt and weebly oAuth
我正在按照 weebly 的文档配置 oauth
但是,将 :jwt 添加到 manage_app_url 不起作用。
令牌永远不会被 jwt 替换,它只是像往常一样简单地附加到末尾 - 将令牌也作为 url.
的一部分
即,在 manifest.json 中执行此操作
"manage_app_url": "https://www.example.com/thepage.php?manage=yes&jwt=:jwt",
Returns:
https://www.example.com/thepage.php?manage=yes&jwt=:jwt?thejwtstring
令牌永远不会被替换...
任何人都知道为什么按照文档所说的操作不起作用?
我做错了什么?
我引用 但在这里回答是因为问题不完全相同。
清单中不需要 :jwt。在您为 manage_app_url 设置的网站页面上,您将收听 jwt,因为正如您所指出的,它会附加到它。
*您也可以使用 "oauth_final_destination" : "manage",如果您希望它们在安装后出现在您的网站上。
{
"manifest": "1",
"version": "1.1.1",
"client_id" : "123456789101112",
"callback_url" : "https://www.your-domain.com/callback.php",
"scopes": ["read:site", "write:site"],
"manage_app_url": "https://www.your-domain.com/manage.php",
"oauth_final_destination" : "manage",
"locale": {
"default": "en-us",
"supported": ["en-us"]
},
"webhooks": {
"callback_url": "https://www.your-domain.com/webhooks.php",
"events": ["app.uninstall", "site.publish", "site.delete"]
},
"snippet": "files/assets/snippet.tpl"
}
在您网站的 manage_app_url 页面上,您可以执行以下操作:
require('firebase/src/JWT.php');
use \Firebase\JWT\JWT;
if (isset($_GET['jwt'])) {
$app_client_id = "Your APP ID";
$client_secret = "Your APP SECRET";
$jtw = $_GET['jwt'];
/**
* You can add a leeway to account for when there is a clock skew times between
* the signing and verifying servers. It is recommended that this leeway should not be bigger than a few minutes.
* Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
*/
try {
JWT::$leeway = 60; // $leeway in seconds
$decoded = JWT::decode($jtw, $client_secret, array('HS256'));
if (!empty($decoded)) {
$decoded_array = (array) $decoded;
// Continue with your websites code to verify the Weebly users info
// $decoded_array['user_id'];
// $decoded_array['site_id'];
// $decoded_array['iat'];
// $decoded_array['jti'];
// $decoded_array['callback_url'];
}
} //END TRY
catch (InvalidArgumentException $e) {
echo $e->getMessage();
}
catch (UnexpectedValueException $e) {
echo $e->getMessage();
}
catch (DomainException $e) {
echo $e->getMessage();
}
}// END IF ISSET JWT
很遗憾,您并没有真正理解这个问题。这不是是否需要 :jwt 的问题,而是它似乎不像文档中那样工作。
这个问题的答案是这样的:
作为草稿应用程序安装时它不起作用,但是,通过应用程序界面访问 "manage app" link 并且它是正确的。即,:jwt 被替换为正确的 url.
所以问题出在草稿应用程序的安装上,而不是在通过前置界面实际管理应用程序上。
该文档对于最终结果是正确的,但对于作为草稿应用安装而言则不正确。这是实际的文档....
NOTE: Weebly automatically appends the JWT string to the end of the URL, including any necessary operands (like ? and &). If you want the JWT to be placed in a specific part of the URL, you can use :jwt, and Weebly will replace that with the JWT (without adding any operands - you'll need to include those).
Bill,你说得对,这是 weebly 的问题,所以你无法修复它。 :jwt 当有人从应用程序管理器菜单中单击管理 link 时替换得很好,但当它来自 OAuth 进程时它替换得不好。
几天前我遇到了同样的问题,只是删除了 :jwt 并让 weebly 将它附加在 URL 的末尾对我有用。
我希望它也对你有用,否则我建议你通过 dev-support@weebly.com 联系 weebly 的开发支持并报告这个问题。
我正在按照 weebly 的文档配置 oauth
但是,将 :jwt 添加到 manage_app_url 不起作用。 令牌永远不会被 jwt 替换,它只是像往常一样简单地附加到末尾 - 将令牌也作为 url.
的一部分即,在 manifest.json 中执行此操作 "manage_app_url": "https://www.example.com/thepage.php?manage=yes&jwt=:jwt",
Returns: https://www.example.com/thepage.php?manage=yes&jwt=:jwt?thejwtstring 令牌永远不会被替换...
任何人都知道为什么按照文档所说的操作不起作用? 我做错了什么?
我引用 但在这里回答是因为问题不完全相同。
清单中不需要 :jwt。在您为 manage_app_url 设置的网站页面上,您将收听 jwt,因为正如您所指出的,它会附加到它。
*您也可以使用 "oauth_final_destination" : "manage",如果您希望它们在安装后出现在您的网站上。
{
"manifest": "1",
"version": "1.1.1",
"client_id" : "123456789101112",
"callback_url" : "https://www.your-domain.com/callback.php",
"scopes": ["read:site", "write:site"],
"manage_app_url": "https://www.your-domain.com/manage.php",
"oauth_final_destination" : "manage",
"locale": {
"default": "en-us",
"supported": ["en-us"]
},
"webhooks": {
"callback_url": "https://www.your-domain.com/webhooks.php",
"events": ["app.uninstall", "site.publish", "site.delete"]
},
"snippet": "files/assets/snippet.tpl"
}
在您网站的 manage_app_url 页面上,您可以执行以下操作:
require('firebase/src/JWT.php');
use \Firebase\JWT\JWT;
if (isset($_GET['jwt'])) {
$app_client_id = "Your APP ID";
$client_secret = "Your APP SECRET";
$jtw = $_GET['jwt'];
/**
* You can add a leeway to account for when there is a clock skew times between
* the signing and verifying servers. It is recommended that this leeway should not be bigger than a few minutes.
* Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
*/
try {
JWT::$leeway = 60; // $leeway in seconds
$decoded = JWT::decode($jtw, $client_secret, array('HS256'));
if (!empty($decoded)) {
$decoded_array = (array) $decoded;
// Continue with your websites code to verify the Weebly users info
// $decoded_array['user_id'];
// $decoded_array['site_id'];
// $decoded_array['iat'];
// $decoded_array['jti'];
// $decoded_array['callback_url'];
}
} //END TRY
catch (InvalidArgumentException $e) {
echo $e->getMessage();
}
catch (UnexpectedValueException $e) {
echo $e->getMessage();
}
catch (DomainException $e) {
echo $e->getMessage();
}
}// END IF ISSET JWT
很遗憾,您并没有真正理解这个问题。这不是是否需要 :jwt 的问题,而是它似乎不像文档中那样工作。
这个问题的答案是这样的: 作为草稿应用程序安装时它不起作用,但是,通过应用程序界面访问 "manage app" link 并且它是正确的。即,:jwt 被替换为正确的 url.
所以问题出在草稿应用程序的安装上,而不是在通过前置界面实际管理应用程序上。
该文档对于最终结果是正确的,但对于作为草稿应用安装而言则不正确。这是实际的文档....
NOTE: Weebly automatically appends the JWT string to the end of the URL, including any necessary operands (like ? and &). If you want the JWT to be placed in a specific part of the URL, you can use :jwt, and Weebly will replace that with the JWT (without adding any operands - you'll need to include those).
Bill,你说得对,这是 weebly 的问题,所以你无法修复它。 :jwt 当有人从应用程序管理器菜单中单击管理 link 时替换得很好,但当它来自 OAuth 进程时它替换得不好。
几天前我遇到了同样的问题,只是删除了 :jwt 并让 weebly 将它附加在 URL 的末尾对我有用。
我希望它也对你有用,否则我建议你通过 dev-support@weebly.com 联系 weebly 的开发支持并报告这个问题。