Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to inject OAuth Services #19

Closed
LeoAdamek opened this issue Jan 3, 2024 · 2 comments
Closed

Unable to inject OAuth Services #19

LeoAdamek opened this issue Jan 3, 2024 · 2 comments

Comments

@LeoAdamek
Copy link

LeoAdamek commented Jan 3, 2024

Previously with the original version of this bundle, I was able to inject the fos_oauth_server.server and fos_oauth_server.storage.default services.

I use this as my authorization and client creation endpoints are implemented in GraphQL. However, in switching to your (very helpful!) fork, any method I try to inject these services fails.

I've tried using a service locator, but it errors with fos_oauth_server.server and fos_oauth_server.storage.default not existing. I've also tried directly injecting the OAuthStorage class which also fails as not existing.

./bin/console debug:container doesn't list either service so I'm confused as to what's going on because I can see their definitions are still present in this repo.

I'll continue to dig and see what I can find but I'm very confused!

My previous implementation looked like this:

# config/services.yaml
services:
  # Map the fos_oauth_server.server to the IOAuth2 interface type.
  OAuth2\IOAuth2:
    alias: fos_oauth_server.server 

  OAuth2\IOAuth2Storage:
    alias: fos_oauth_server.storage.default
# src/GraphQL/Mutations/OAuthMutation.php
class OAuthMutation {
  public function __constuct(
     /* ... other arguments */, 
    private readonly IOAuth2 $oauth2, 
    private readonly IOAuth2Storage $authStorage) 
  { }
}

However now neither service seems to exist and the container fails to compile.

@LeoAdamek
Copy link
Author

Disregard, somehow in the process of swapping, the bundles.php config got mangled with the following:

FOS\OAuthServerBundle\FOSOAuthServerBundle::class => [0 => true, 1 => true]
instead of ['all' => true]

Not sure how this happened but that meant the bundle wasn't even loaded!

@klapaudius
Copy link
Owner

Hello,

I'm glad that this repo helps you too. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants