-
Notifications
You must be signed in to change notification settings - Fork 176
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
Can't get web auth to work with my own authentication server #154
Comments
The
This looks like the correct approach to me, could it possibly be that there needs to be something more in the url? Could you try changing this to something like: c.Redirect(http.StatusFound, "callback-scheme://success") Also, which platform are you targeting? |
Yes, I understood that. For now I'm testing the setup with chrome, so I went for the web approach, but I'm not getting anything back for
Ideally, all of them :) I'm going to try on android just now (it's not as easy as the web approach because of the networking) |
Ah, I see. Unfortunately I haven't personally tested the web setup much, it was contributed by someone else. Could you try the example app in this repo and see if that works for you? |
Ok it also doesn't work for Android (we can focus on this platform for now if you have worked with it more). Server: func AuthCallback(c *gin.Context) {
user, err := gothic.CompleteUserAuth(c.Writer, c.Request)
...
c.Redirect(http.StatusFound, "callback-scheme://success")
} Client: final result = await FlutterWebAuth.authenticate(
url: url, callbackUrlScheme: "callback-scheme");
print("result: $result"); What I see on the phone:
I'm not sure how it should work here, if Should I do something like this on the server side: func AuthCallback(c *gin.Context) {
user, err := gothic.CompleteUserAuth(c.Writer, c.Request)
...
// httpOnly MUST be set to true for security
c.SetCookie(
"refresh_token",
refreshToken,
int(VALIDITY_REFRESH_TOKEN.Seconds()),
"/",
HOST,
false,
true,
)
c.Redirect(http.StatusFound, "callback-scheme://success")
} |
Ok I got it working on Android. My mistake was to generate the oauth URL and returning it as a json payload, instead of just redirecting to the url: func Login(c *gin.Context) {
...
url, err := gothic.GetAuthURL(c.Writer, c.Request)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
}
// c.JSON(http.StatusOK, gin.H{"redirect": url}) // NOT GOOD
c.Redirect(http.StatusFound, url)
} The rest is unchanged. Now unfortunately this doesn't work with web as is. |
I tried it. I don't think it works. First, I needed to run with I got it to run (no error, authentication page displaying properly in browser), when I click the auth button I'm redirected to the expected url but I don't see the result of |
Hello,
I have my own authentication service to authenticate my users. The service is written in Go. The authentication flow works like this:
http://localhost:8080/auth/facebook
http://localhost:8080/auth/callback
with the user info (I do stuff with this data, like adding the user to a database)The above works. I'm now trying to build the UI. So far I have something like this:
On the server side, this is the implementation of the
/auth/callback
endpoint:I tried serving the
auth.html
page mentioned here from the server. With this setup, I can click the Facebook button, the web page opens, I can login on Facebook, and I can give permissions to the app. I'm then redirected to theauth.html
page, and then...nada. I never get back anything forfinal result =...
(on the client side). There is no error in the flutter console.I tried other stuff on the server side:
With this, I ultimately a json blob with the
hello
token in the web page that opens, but I'm not getting anything back on the client side.I'm missing something, but I don't know what. Would you be able to help please?
The text was updated successfully, but these errors were encountered: