#Swift's access control rules
1 messages · Page 1 of 1 (latest)
Which variable can't you see?
i cant access:
try await app.oauth.google.make<EmailAccessToken>(service: oauthGoogle)
defined in;
public extension Application.OAuth {
public var google: Google {
.init(_oauth: self)
}
...
having the function:
public func make<Token>(service: GoogleService) where Token: GoogleToken & Authenticatable {
let router = OAuthRouter<GoogleService, Token>(service)
try await self._oauth._application.oauth
.services.register(app: self._oauth._application, service, router: router)
}
}
defined in its type value
So you can't access the google variable or the make function?
neither
What's the error?
i can access app.oauth.services.register though and it is of type Application.oauth i assume to be correct when i believe that the access control for the application object is not in question.
Value of type 'Application.OAuth' has no member 'google'
Hmm looks like it should work
Make sure you're using the latest packages
And best option is to try it in the OAuth Tests (without using @testable)
(And check from the command line and not Xcode)
alright, thats what i was looking for
will have a look tomorrow
you did explicitly import the module right?
I would first clean up your access control usage - in some places you’re using ‘public extension’ with explicitly declared public properties, in some places you’re not. I try to keep a code style just writing extensions as extension - then expose what you need explicitly as public
yes it is kind of a cry for help so to speak
yes the import is explicit
its driving me nuts
Okay I've got a simple answer for you 😅
Your repo bwdmr/oauth (https://github.com/bwdmr/oauth) isn't exposing the Vendor folder at all
Since your Package.swift is defining OAuth as a target, it is only including the source from Sources/OAuth
You need to move the Vendor folder inside OAuth
Or if you really want to keep that structure, define the target like so with path set explicitly:
.target(
name: "OAuth",
dependencies: [
.product(name: "OAuthKit", package: "oauth-kit"),
.product(name: "Vapor", package: "vapor")
],
path: "Sources"
)
there are some other issues too though - your make<Token> method needs to be rewritten to include the actual token type as a parameter rather than trying to specialise at the call site with app.oauth.google.make<EmailAccessToken>(...)
this is better
public func make<Token>(service: GoogleService, tokenType: Token.Type) async throws where Token: GoogleToken & Authenticatable {
// ...
}
then just add Authenticatable to your EmailAccessToken and you can call
try await app.oauth.google.make(service: oauthGoogle, tokenType: EmailAccessToken.self)
and everything compiles just fine 😄
oh god
0xA0 gave a
to @solemn inlet, who now has 14
!
@violet haven what do you think. how does this look
What does what look?
the package its done. its awesome. tell me its awesome 🙂