我正在尝试使用 FOSOAuthServerBundle。它工作得很好,但我试着让它在 API 中工作......当我注册一个新用户时,我创建了一个新客户端,我想直接给他授权。access_token 的请求将在用户登录时完成...
问题,文档中给出的示例,它重定向到授权页面,然后重定向到一个URL......如果没有任何重定向,它会很棒,只是为了使授权......
我的部分注册码:
$user->setUsername($name);
$user->setEmail($email);
$encoder = $this->get('security.encoder_factory')->getEncoder($user);
$password_user = $encoder->encodePassword($password, $user->getSalt());
$user->setPassword($password_user);
$clientManager = $this->get('fos_oauth_server.client_manager.default');
$client = $clientManager->createClient();
$client->setRedirectUris(array('http://localhost:8888/app_dev.php'));
$client->setAllowedGrantTypes(array('token', 'authorization_code'));
$clientManager->updateClient($client);
$user->setClient($client);
// Here we would like to authorize the user witout redirection :
return $this->redirect($this->generateUrl('fos_oauth_server_authorize', array(
'client_id' => $client->getPublicId(),
'redirect_uri' => 'http://localhost:8888/app_dev.php',
'response_type' => 'code'
)));
我想在没有任何重定向的情况下进行授权...因为它在 API :/ 中,所以没有 URL...还有其他授权方式吗?
谢谢