oauth2_client icon indicating copy to clipboard operation
oauth2_client copied to clipboard

Https redirect not working

Open j555 opened this issue 4 years ago • 9 comments
trafficstars

The Oauth provider I am using recently moved to requiring https redirects. Everything was working when an https redirect was not required. Now when I run the app I get redirected to the https redirect I set up and the browser window doesn't close and the token is never received.

I set up the app link and tested it at https://developers.google.com/digital-asset-links/tools/generator. It gives me a success message.

When I am forwarded to the https redirect the URL contains a code variable and a state variable.

The code I am using is as follows:

  OAuth2Client client = ClioOAuth2Client(
      redirectUri: 'https://oauth.mydomain.net/oauth/approval',
      customUriScheme: 'https');

  OAuth2Helper oauth2Helper = OAuth2Helper(client,
      grantType: OAuth2Helper.AUTHORIZATION_CODE, //default value, can be omitted
      clientId: 'clientid',
      clientSecret: 'secret',
      scopes: ['tasks']);

AndroidManifest:

        <intent-filter android:label="flutter_web_auth" android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https"
                android:host="oauth.mydomain.net"
                android:pathPrefix="/oauth/approval" />
        </intent-filter>

When the app runs the authorizeUrl is received but it seems to hang when it gets to final result = await webAuthClient.authenticate( url: authorizeUrl, callbackUrlScheme: customUriScheme);

Does anyone have any idea what I am doing wrong?

Thanks for the help!

j555 avatar May 30 '21 13:05 j555

Hi @j555, from your example it's not clear if the intent-filter is inside an activity tag, and if so, if it is declared correctly:

<activity android:name="com.linusu.flutter_web_auth.CallbackActivity" >
	<intent-filter android:label="flutter_web_auth" android:autoVerify="true">
		<action android:name="android.intent.action.VIEW" />
		<category android:name="android.intent.category.DEFAULT" />
		<category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="https"
                   android:host="oauth.mydomain.net"
                   android:pathPrefix="/oauth/approval" />
	</intent-filter>
</activity>

okrad avatar Jun 09 '21 21:06 okrad

Sorry for the late response. The intent-filter is inside an activity tag and appears to be declared correctly, but it is still not working. It opens the redirect URI in a browser and then just sits with no error at all. Any other ideas as to what may be wrong?

Thank you

j555 avatar Jul 07 '21 14:07 j555

Same challenge. The URI Browser stays open. Subscribed to this thread to see if any solutions pop up.

jamesdayhuff avatar Jul 27 '21 20:07 jamesdayhuff

i'm having the same problem on iOS 14. i never get the result back from the .authenticate method. i took a look at the native iOS code in the library, and it seems to be correctly making use of ASWebAuthenticationSession. but the browser that opens for the third-party oauth login never closes, and original application remains in the background.

seidlere avatar Oct 04 '21 18:10 seidlere

I'm having the same issue over here, the Https request is blocking the callback to my flutter app and I do not know what to do. Once the webauthentication is done the url page is correctly redirected to web 127.0.0.1 but then I just stay with an error and don't come back to my app.

noe-gif avatar Oct 09 '21 16:10 noe-gif

Any Update on this?

KushalxPathak avatar Mar 11 '22 03:03 KushalxPathak

@j555 the intent-filter does not need to be in an activity tag, as far as I know it needs to be in the com.linusu.flutter_web_auth.CallbackActivity activity tag.

supermar1010 avatar Mar 13 '22 16:03 supermar1010

@supermar1010 @j555 declared intent-filter in com.linusu.flutter_web_auth.CallbackActivity activity tag (as per ReadMe)documentation.Issue remains the same for me too.

KushalxPathak avatar Mar 14 '22 03:03 KushalxPathak

@KushalxPathak I've never done that so I'm not sure, but did you do the verifying you own the url?

"Add verification for your deep links: Configure your app to request verification of app links. Then, publish a Digital Asset Links JSON file on your websites to verify ownership through Google Search Console. Learn more in Verify App Links." This is from the Google docs linked under app link in troubleshooting

supermar1010 avatar Mar 14 '22 07:03 supermar1010