我在一个全新的sylius项目(0.17.0)上用oauth尝试了sylius API。但是在每个简单的api-call上都有有效的访问令牌,响应总是301重定向到路由" / connect"。
php app/console sylius:oauth-server:create-client --grant-type="password"
输出:
"具有公共ID的新客户端 3ogfp09nbikg440ssg4ss84k4ww4wgw00gc8w4kksskggoocso,secret 4vawhwsg4hwk8gocgk08ogkcgwgswo0k0og0w0cgkk8g8cgsg4已添加"
curl http://www.domain.dev/oauth/v2/token \
-d "client_id"=3ogfp09nbikg440ssg4ss84k4ww4wgw00gc8w4kksskggoocso \
-d "client_secret"=4vawhwsg4hwk8gocgk08ogkcgwgswo0k0og0w0cgkk8g8cgsg4 \
-d "grant_type"=password \
-d "username"=myvalidusername \
-d "password"=myvalidpassword
一切正常:
{ "access_token":"MDUxZWQ4M2U0ZmJmNTEyZTdkNDRlMjkxY2E3MTE2ZTM0ZDVkZjMwZjEyNjRiOWZlMTdkMmJkOTA1ZmFiNGFmMA",
"expires_in":3600,
"token_type":"bearer",
"scope":null,
"refresh_token":"NWNmZjkwNTM1MWNiMDU5OWVhN2NjOGQ5N2U5MGFiYTkxYWVlYmNiNDBkNTJlNzJjZjE1MzI1MjI5MzI2YTc3Nw"
}
卷曲http://www.domain.dev/api/users/ -H"授权:持票人MDUxZWQ4M2U0ZmJmNTEyZTdkNDRlMjkxY2E3MTE2ZTM0ZDVkZjMwZjEyNjRiOWZlMTdkMmJkOTA1ZmFiNGFmMA"
输出是:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="refresh" content="1;url=http://www.domain.dev/connect" />
<title>Redirecting to http://www.domain.dev/connect</title>
</head>
<body>
Redirecting to <a href="http://www.domain.dev/connect">http://www.domain.dev/connect</a>.
</body>
</html>