Faisalkc4u / uae_pass

MIT License
6 stars 10 forks source link

Wrong variable names #2

Closed anakin001 closed 1 year ago

anakin001 commented 1 year ago

In uae_pass.dart: line 11: remove '://' line40: getAuthToken -> getAccessToken In uae_pass_method_channel.dart: line 40: getAuthToken -> getAccessToken line 41:auth_token -> access_token In uae_pass_platform_interface.dart: line 35 & 36: getAccessToken

Faisalkc4u commented 1 year ago

@anakin001 Thanks for the comments

anakin001 commented 1 year ago

In uae_pass_method_channel.dart: line 49:auth_token -> access_token this has not been resolved

faisalkcmvp commented 1 year ago

I created another method for that

https://github.com/Faisalkc4u/uae_pass/blob/998fe6b76edd7e7ea13d0861834f91f05a65cf45/lib/uae_pass_method_channel.dart#L50

faisalkcmvp commented 1 year ago

Once you receive the access auth token, better to use this method to convert to auth code to the access token. Both android and iOS work differently.

curl --location --request POST 'https://stg-id.uaepass.ae/idshub/token?grant_type=authorization_code&redirect_uri=https://stg-selfcare.uaepass.ae&code=bfe96299-83f4-3ee9-80e4-56c24f5265d3' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Basic c2FuZGJveF9zdGFnZTpzYW5kYm94X3N0YWdl'
anakin001 commented 1 year ago

https://github.com/Faisalkc4u/uae_pass/blob/6ece944f25612092ecc5db00c5bf9bd8c2e438d3/android/src/main/kotlin/com/mvpapps/uae_pass_flutter/UaePassFlutterPlugin.kt#L157

auth_token wasnt implemented

Faisalkc4u commented 1 year ago

Both android and ios behave differently

Android to get auth token we need call the sign in again ios It converts the auth code token token directly

For a best approach do it on the flutter by using dio/http package or server side.

Once received the auto code you can convert it by hitting the POST method Refer here.

anakin001 commented 1 year ago

image

This is my code, Ive tested in android, I managed to get the user info. Not sure if it works on IOS

faisalkcmvp commented 1 year ago

Don't use the _usePassPlugin.getAccessToken()

instead use

  final FormData formData = FormData.fromMap({
      "grant_type": "authorization_code",
      "redirect_uri": "https://stg-selfcare.uaepass.ae",
      "code": "bfe96299-83f4-3ee9-80e4-56c24f5265d3"
    });

    String username = 'client_id';
    String password = 'client_secret';
    String basicAuth =
        'Basic ${base64.encode(utf8.encode('$username:$password'))}';
    Dio().post("https://stg-id.uaepass.ae/idshub/token",
        data: formData,
        options: Options(headers: {"Authorization": basicAuth}));
anakin001 commented 1 year ago

Don't use the _usePassPlugin.getAccessToken()

instead use

  final FormData formData = FormData.fromMap({
      "grant_type": "authorization_code",
      "redirect_uri": "https://stg-selfcare.uaepass.ae",
      "code": "bfe96299-83f4-3ee9-80e4-56c24f5265d3"
    });

    String username = 'client_id';
    String password = 'client_secret';
    String basicAuth =
        'Basic ${base64.encode(utf8.encode('$username:$password'))}';
    Dio().post("https://stg-id.uaepass.ae/idshub/token",
        data: formData,
        options: Options(headers: {"Authorization": basicAuth}));

thanks @faisalkcmvp

anakin001 commented 1 year ago

image Is it normal that I dont get a refresh token in response? Or it's not available in staging?

faisalkcmvp commented 1 year ago

Am not sure about that, At this stage, you need an access_token to get the user info.

Note: