Oauth令牌加密和哈希

时间:2014-10-07 14:58:34

标签: encryption oauth apigee

在响应中,在api中生成oauth令牌 我们需要加密oauth令牌,然后用时间戳加盐并哈希吧

使用客户端凭据,客户端正在接近apigee。但作为回应如何加密oauth令牌,然后盐与时间戳和哈希呢?

 curl https://{org}-test.apigee.net/oauth/client_credential/
  accesstoken?grant_type=client_credentials -X POST -d 
  'client_id={consumer_key}&client_secret={consumer_secret}'

响应如下

   {  
  "issued_at" : "1382703699776",
   "application_name" : "8586c7b7-2936-4779-b7a6-97014e436d7d",
  "scope" : "READ",
  "status" : "approved",
  "api_product_list" : "[PremiumWeatherAPI]",
  "expires_in" : "3599",
  "developer.email" : "tesla@weathersample.com",
  "organization_id" : "0",
  "client_id" : "SJOaCEGohSu3vpNswMs5YdBlc2GOAh1J",
  "access_token" : "UAj2yiGAcMZGxfN2DhcUbl9v8WsR",
  "organization_name" : "myorg",
  "refresh_token_expires_in" : "0",
  "refresh_count" : "0"
   }

作为响应,我需要使用时间戳加密oauth访问令牌和salt,然后对其进行哈希处理。 怎么做

1 个答案:

答案 0 :(得分:0)

您可以使用以下方法:

  • 在生成访问令牌策略之后,您将能够访问oauthv2accesstoken.{policy_name}.access_token变量。使用assign message策略将此值分配给变量。
  • 接下来,为了计算哈希,您需要在流的响应部分中使用java,python或javascript策略。这个link有一个sha256的示例JavaScript。