HWIOAuthBundle期望从infos_url得到什么



我正试图用HWIOAuthBundle配置我的oauth2服务器,我想澄清一下HWIOAuthBundle期望作为正确配置infos_url的响应?

我猜它正在期待一个json文件。那么,它的场是什么?如果你有链接,我会很高兴。

hwi_oauth:
    firewall_name: main
    resource_owners:
        battlenet:
            type: oauth2
            client_id: "%client_id%"
            client_secret: "%client_secret%"
            access_token_url: %path%/oauth/token
            authorization_url:  %path%/oauth/authorize
            infos_url:  %path%/user/me
            scope: "read"
            user_response_class: HWIBundleOAuthBundleOAuthResponsePathUserResponse
            paths:
                identifier: id
                nickname: id
                realname: id

谢谢,)

我知道怎么做了!您必须为用户创建一个简单的API,如下所示:

路由:

# app/routing.yml
api_users:
    pattern: /api/users.json
    defaults: { _controller: AppOAuthServerBundle:User:getUser }
    options:
        i18n: false

控制器:

<?php
namespace AppOAuthServerBundleController;
use AppGeneralBundleEntityUser;
use FOSRestBundleControllerFOSRestController;
class UserController extends FOSRestController
{
    public function getUserAction()
    {
        $user = $this->get('security.context')->getToken()->getUser();
        if ( $user instanceof User ) {
            $data = array(
                'id' => $user->getId(),
                'username' => $user->getUsername(),
                'realname' => $user->getFirstname().' '.$user->getLastname(),
                'email'    => $user->getEmail(),
            );
        } else {
            $data = array();
        }

        $view = $this->view($data, 200)
            ->setTemplate('AppOAuthServerBundle:Default:index.html.twig')
            ->setFormat('json')
            ->setTemplateVar('user');
        return $this->handleView($view);
    }
}

相关内容

  • 没有找到相关文章