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

OAuth2 redirect issues #93

Open
noe-gif opened this issue Oct 10, 2021 · 4 comments
Open

OAuth2 redirect issues #93

noe-gif opened this issue Oct 10, 2021 · 4 comments

Comments

@noe-gif
Copy link

noe-gif commented Oct 10, 2021

Hello, I've read previous issues similar as mine but I still can't manage to make it work with all this information

So, as I understood your scheme needs to be structured as following : domain.company.name
and the idea would be that your url is just your scheme + ://

(Just to clarify, I'm trying to use Reddit's Oauth, with reddit you need to create a dev app and get your clientID and secrets (https://www.reddit.com/prefs/apps))

The thing is I can't just put domain.company.name:// as url in here :

image

So what I did previously was putting http://127.0.0.1:65010/authorize_callaback and http as scheme.

My issue is that when I click on accept to authorize with OAuth2 it gets me here when it's supposed to go back on the app :

image

Even tho I get my token in the url : http://127.0.0.1:65010/authorize_callback?state=random_string&code=_2stEhVnH294rcna_DqnRGKRv3w1lw#_

I'm really stuck here so if anyone can help me that would be great, here is my code :

main.dart :

  final url = Uri.https('www.reddit.com', '/api/v1/authorize.compact', {
    'client_id': googleClientId,
    'response_type': 'code',
    'state': '$randomString',
    'redirect_uri': 'http://127.0.0.1:65010/authorize_callback',
    'duration': '$timeVariable',
    'scope': '$scopeList',
  });
  final result = await FlutterWebAuth.authenticate(
      url: url.toString(), callbackUrlScheme: "http", preferEphemeral: true);

AndroidManifest.xml :

(I didn't put this inside the .MainActivity)

	<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
            <intent-filter android:label="flutter_web_auth">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http"
              		  android:host="authorize_callback"
              		  android:pathPrefix="/authorize_callback" />
            </intent-filter>
        </activity>

Thanks

@Yodart
Copy link

Yodart commented Oct 24, 2021

Stuck on the same problem here. Would like to note that this also occurs for https callback urls

@noe-gif
Copy link
Author

noe-gif commented Oct 24, 2021

Stuck on the same problem here. Would like to note that this also occurs for https callback urls

I fixed the problem for basically no reason ^^ I changed redirect url to : domein.society.name://http://127.0.0.1:65010/authorize_callback

And it basically works so there you go

@Yodart
Copy link

Yodart commented Oct 24, 2021

Hey, @noe-gif Thanks for your response. That isn't really a fix tho, you're just using a custom URL scheme now. After further investigating I found that ASWebAuthenticationSession only uses custom callback URL schemes, to use http/https schemes the library would have to implement a solution using WKWebview (which is what the flutter_webview library uses)

@rachittiwari8562
Copy link

rachittiwari8562 commented Feb 10, 2022

Stuck on the same problem here. Would like to note that this also occurs for https callback urls

I fixed the problem for basically no reason ^^ I changed redirect url to : domein.society.name://http://127.0.0.1:65010/authorize_callback

And it basically works so there you go

Can you please share your manifest and redirct uri and callback uri......
I am also stuck in this

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

3 participants