GoogleChrome / android-browser-helper

The Android Browser Helper library helps developers use Custom Tabs and Trusted Web Activities on top of the AndroidX browser support library.
Apache License 2.0
700 stars 289 forks source link

help with adding custom headers #277

Open GoldaEV opened 3 years ago

GoldaEV commented 3 years ago

help with adding custom headers photo_2021-04-06_14-05-30 this is a screenshot from an example. My code doesn't work either. in Mainifest.xml <meta-data android:name="asset_statements" android:resource="@string/asset_statements" /> in string.xml <string name="asset_statements" translatable="false">[{ \"include\": \"https://qwerty.com/.well-known/assetlinks.json\" }] </string>

file from site: https://qwerty.com/.well-known/assetlinks.json [{ "relation": ["delegate_permission/common.use_as_origin"], "target" : { "namespace": "android_app", "package_name": "my.app.android", "sha256_cert_fingerprints": ["52:52:52:52:36:D9:4E:F3:DB:E5:3E:0E:7A:2D:3C:D8:08:8E:7A:FF:56:FC:30:E0:59:AC:05:43:CE:CE:CE:CE"] } }] the rest of the code is as in the example [(https://developer.chrome.com/docs/android/custom-tabs/headers/)]

andreban commented 3 years ago

Trying to access https://qwerty.com/.well-known/assetlinks.json says the site is offline. The screenshot also seems to point to https://custom-tabs-custom-he.glitch.me/, which is not the site being validated. You should open a URL in https://qwerty.com since it's the origin being validated.

GoldaEV commented 3 years ago

qwerty.com was for example real - https://api.busy-fly.com/.well-known/assetlinks.json

andreban commented 3 years ago

qwerty.com was for example real - https://api.busy-fly.com/.well-known/assetlinks.json

The asselinks file looks correct (assuming fingerprints match). So, the custom headers will only be sent when opening URLS under https://api.busy-fly.com.

GoldaEV commented 3 years ago

fingerprint taken with the utility изображение

but my full address looks like "https://api.busy-fly.com/end-user-api/v1/balance-package-purchase-payment-form?balance_package_id=${packageId}")

GoldaEV commented 3 years ago

also does not work with fingerprint keytool -list -v -keystore PATH_TO_KEYSTORE -alias VALUE_OF_ALIAS

andreban commented 3 years ago

I tested this today and can see it working. I did find a couple of issues in the demo application and submitted #280 with fixes. Can you try with those fixes?

I just tested in an emulator with Chrome 89 and can see the demo working: Screenshot_1618231281

Maybe it's worth trying to remix the demo here https://glitch.com/edit/#!/custom-tabs-custom-he and changing public/.well-known/assetlinks.json to reflect your own app, then modify the URL on the Android demo.

DmitryDogar commented 3 years ago

This headers

      headers.putString("bearer-token", "Some token");
      headers.putString("redirect-url", "Some redirect url");

Also not working for me, even with correctly configured .well-known/assetlinks.json Chrome 90.0.4430.91

lionandbull commented 3 years ago

Hi guys, if you cannot see the extra headers from your app, the following info might be helpful.

  1. Find the /.well-known/assetlinks.json from https://glitch.com/edit/#!/custom-tabs-custom-he, you will not be able to see the .well-known folder on the left panel since it's a hidden folder. Click the "Remix to Edit" from the right top pop-up window, it will clone the project into your account. Then you can click the "Tools" on the left bottom, then "Terminal", and cd to ./public/.well-known and you'll see the assetlinks.json file.
  2. Replace the "sha256_cert_fingerprints" with yours.
  3. Make sure it contains "use_as_origin" relation "relation": ["delegate_permission/common.use_as_origin"]

Tested with Chrome 90.0.4430.210

namnh-0652 commented 2 years ago

@andreban I setup my assetlinks file here https://namnh-0652.github.io/.well-known/assetlinks.json and try the demo app with my link "https://namnh-0652.github.io" but no headers are added.

CCT version 9x.

@DmitryDogar , @lionandbull any updated status from you guys?

rocklass commented 2 years ago

@andreban I setup my assetlinks file here https://namnh-0652.github.io/.well-known/assetlinks.json and try the demo app with my link "https://namnh-0652.github.io" but no headers are added.

CCT version 9x.

@DmitryDogar , @lionandbull any updated status from you guys?

Same issue for me with the demo app (here is my assetlinks file)