variable representing the redirectURL, which is dictated by the oauth2 provider.
is named callback.
example:
public class GitlabRouter: FederatedServiceRouter {
...
public required init(callback: String, completion: @escaping (Request, String) throws ->
...
a few router have a callbackURL, representing the same thing this hardcoded. example:
public static var baseURL: String = "https://gitlab.com/"
public static var callbackURL: String = "callback"
on top a function which handles the "callback" made on the "callback" sometimes referred to as "callbackURL" is named... you guessed it. "callback"
public func callback(_ request: Request) throws -> EventLoopFuture<Response> {
return try self.fetchToken(from: request).flatMap { accessToken in
let session = request.session
do {
try session.setAccessToken(accessToken)
try session.set("access_token_service", to: self.service)
return try self.callbackCompletion(request, accessToken).flatMap { response in
return response.encodeResponse(for: request)
}
} catch {
return request.eventLoop.makeFailedFuture(error)
}
}
}
additionally callback is a reserved word, in a sense it is a descriptive term well known in IT.
for all these reasons, id like to rename it. following changes would apply
callback passed to FederatedServiceRouter should be named redirectURL/redirectURI, because it is the copied value from the oauth provider named redirect_uri .
callback function which handles the route for the redirect_uri, would be named handleoauthRedirect
files representing related content, GoogleCallbackBody.swift´, would be renamed toGoogleOauthRedirectBody.swift`
furthermore what is the background behind those static references?
// ImperialDiscord/DiscordRouter.swift
...
public class DiscordRouter: FederatedServiceRouter {
public static var baseURL: String = "https://discord.com/"
public static var callbackURL: String = "callback"
...
var components = URLComponents()
components.scheme = "https"
components.host = "discord.com"
components.path = "/api/oauth2/authorize"
components.queryItems = [
clientIDItem,
.init(name: "redirect_uri", value: DiscordRouter.callbackURL),
.init(name: "response_type", value: "code"),
scopeItem
]
the auth url could only be wrong for it would not be dictated by the provider.
this ill let be, for the moment...
all is open for discussion! please let me know what you thing, your input and thoughts.
variable representing the redirectURL, which is dictated by the oauth2 provider. is named callback.
example:
a few router have a callbackURL, representing the same thing this hardcoded. example:
on top a function which handles the "callback" made on the "callback" sometimes referred to as "callbackURL" is named... you guessed it. "callback"
additionally callback is a reserved word, in a sense it is a descriptive term well known in IT.
for all these reasons, id like to rename it. following changes would apply
redirectURL
/redirectURI
, because it is the copied value from the oauth provider namedredirect_uri
.redirect_uri
, would be namedhandleoauthRedirect
GoogleCallbackBody.swift´, would be renamed to
GoogleOauthRedirectBody.swift`furthermore what is the background behind those static references?
the auth url could only be wrong for it would not be dictated by the provider. this ill let be, for the moment...
all is open for discussion! please let me know what you thing, your input and thoughts.