Sylius:使用OAuth-Token的API调用始终重定向到" connect" -Route

时间:2016-04-06 13:30:31

标签: php symfony oauth sylius

我在一个全新的sylius项目(0.17.0)上用oauth尝试了sylius API。但是在每个简单的api-call上都有有效的访问令牌,响应总是301重定向到路由" / connect"。

我做了什么:

1。创建API CLient:

php app/console sylius:oauth-server:create-client --grant-type="password"

输出:

  

"具有公共ID的新客户端   3ogfp09nbikg440ssg4ss84k4ww4wgw00gc8w4kksskggoocso,secret   4vawhwsg4hwk8gocgk08ogkcgwgswo0k0og0w0cgkk8g8cgsg4已添加"

2。获取令牌:

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"
}

3。使用带有令牌的授权作为http标头进行简单的API调用:

卷曲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>

0 个答案:

没有答案