Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

ClientException "failed to parse header value" #74

Open
SetNameHere opened this issue May 29, 2020 · 1 comment
Open

ClientException "failed to parse header value" #74

SetNameHere opened this issue May 29, 2020 · 1 comment

Comments

@SetNameHere
Copy link

SetNameHere commented May 29, 2020

Hi,

first of all thanks for your work on this package!

I'm trying to develop a flutter (web) application which needs to invoke access restricted Cloud Functions.

Therefore I have created a service account in my google cloud console and followed your example on how to retrieve an authenticated http client as an autonomous application.

final accountCredentials = new ServiceAccountCredentials.fromJson(r'''{ "private_key_id": "****", "private_key": "****", "client_email": "****.iam.gserviceaccount.com", "client_id": "****", "type": "service_account" }'''); var scopes = [CloudfunctionsApi.CloudPlatformScope]; AuthClient client = await clientViaServiceAccount(accountCredentials, scopes);

This seems to work fine. But when I try to use the received client to make a post request to my cloud function, I get a ClientException ("failed to parse header value").

http.Response resp = await client.post( CloudFunctiontriggerURL, body: {'data': userId});

As I understand the examples, this should work fine without specifying any headers manually in the POST function call. Correct?
However, even if I specify the header manually, I get this error.

Any help with this would be highly appreciated.

@SetNameHere
Copy link
Author

I think I have found the key issue. I have to explicitly add the ID Token to the request.
However similar to this issue #52, the ID Token I receive within the client is always null.

Could any one tell me how I can retrieve a valid ID Token using this package?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant