MaikuB / flutter_appauth

A Flutter wrapper for AppAuth iOS and Android SDKs
270 stars 243 forks source link

Issues on Access Token Format Check the access token in jwt.io it shows this is not valid accesstoken it require high level json object and access token looks bit smaller #303

Closed AgnRakul closed 2 years ago

MaikuB commented 2 years ago

There are no issues with the access token. As mentioned in #298, there's an example app in the repo. If you clone/download the repo, run it and analyse it, you'll find that it is about to use the access token to successfully call an API. Before reporting an issue, please ensure you run the example app first. Also consider what kind of issue it is. In this case, if what you said was true, that this should mean a lot of people would report this issue and that calling the API in the example should fail. That isn't the case however, there's an issue on your end, like in #298. In cases like this, you should use community sites like stack overflow, discord and slack. When you do, ensure that you include as much info as you to ensure your problem can be reproduced by others too.

As for your issue, I'm pretty confident what you did was you printed the access token without using it call an API. Printing it won't work due to https://github.com/flutter/flutter/issues/22665

AgnRakul commented 2 years ago

Kindly Check The Parsing Function of AccessToken. The Token Comes as Jwt Format after that there is Parsing function on you Example if we parse it again it provide another different string and if check the string on JWT.io it shows its not valid token and I haved Checked that in postman its shows JWT MALFORMED

MaikuB commented 2 years ago

There is nothing wrong with it. Please take a closer look at what I written to compare with what you're doing, especially with what I wrote in the last paragraph in my previous response. Common sense would say that if what you said is true then that would mean no one would be able to use the plugin too hit secured APIs. That isn't the case. So far you haven't provided really provided evidence to prove there's an issue

AgnRakul commented 2 years ago

Kindly Check it once this article is this Article is Correct https://auth0.com/blog/flutter-authentication-authorization-with-auth0-part-1-adding-authentication-to-an-app/

MaikuB commented 2 years ago

Yes but did you read what I wrote here?

As for your issue, I'm pretty confident what you did was you printed the access token without using it call an API. Printing it won't work due to https://github.com/flutter/flutter/issues/22665

AgnRakul commented 2 years ago

Auth0IdToken parseIdToken(String idToken) { final parts = idToken.split(r'.'); assert(parts.length == 3); final Map<String, dynamic> json = jsonDecode( utf8.decode( base64Url.decode( base64Url.normalize(parts[1]), ), ), ); debugPrint(idToken); // This Provides al Long String return Auth0IdToken.fromJson(json); }

// Retriving User Information Future getUserDetails(String accessToken) async { final url = Uri.https(auth0Domain, '/userinfo'); final response = await http.get(url, headers: {'Authorization': 'Bearer $accessToken'}); debugPrint(auth0AccessToken); // THis Provides a Parsed String debugPrint('getUserDetails ${response.body}'); if (response.statusCode == 200) { return Auth0User.fromJson(jsonDecode(response.body)); } else { throw Exception('Failed to get user details'); } }

The Issues Where I need pass IdToken or accesstoken to my backend to validate and sent reponse to my frontend

MaikuB commented 2 years ago

Note you haven't answered me question and what you provide isn't evidence of an issue. I had said before that you cannot use what gets printed to due a limitation on Flutter. Your code snippet would show that you are doing this despite what I said and been trying to make sure you understand

AgnRakul commented 2 years ago

Yeah I Understood but make sure the mentioned article is correct ?

MaikuB commented 2 years ago

I had answered that. It looks right but note that I'm not the author of the article and the article was written months ago. If you are trying to follow the steps in the article you should contact the author or use the Auth0 forums to see if anyone else has had the same issues. To repeat, you've still yet to provide evidence of issues with the plugin.

I'll rephrase the question using the example app. You said you confirmed the jwt from using the example app is malformed, what are the exact steps you took to validate this? Could you record how you checked this?

AgnRakul commented 2 years ago

Yeah I Thought Because of Parsing the accessToken The String convert to another format I Just Copies from console i Check in Postman is shows that Error Now I UNDERSTOOD the error about the console log string

MaikuB commented 2 years ago

Closing this. I'd ask that you take a closer read of what is written and do more analysis of issues in the future. This helps ensure open source software can be maintained in a more sustainable manner as a lot of it is done in spare time and responding to issues like this takes a lot of time too

AgnRakul commented 2 years ago

Yeah Sorry for the That Anyway thanks for you response