Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

After Authorization user not redirected to App #466

Open
1 of 2 tasks
aashish181188 opened this issue Jul 5, 2022 · 1 comment
Open
1 of 2 tasks

After Authorization user not redirected to App #466

aashish181188 opened this issue Jul 5, 2022 · 1 comment

Comments

@aashish181188
Copy link

aashish181188 commented Jul 5, 2022

Xamarin.Auth Issue

The Mobile App is integrated with Salesforce and authentication done using oAuth2.
After Login page user redirect to Allow Access screen . On Allow Access click user stays on the same screen and not redirected to
Mobile App .
IF BUG, INCLUDE THIS PART:
After Login page user redirect to Allow Access screen . On Allow Access click user stays on the same screen and not redirected to Mobile App .

Version

  • nuget version = 1.7.0
  • component version =

void LoginToSF(bool allowCancel)
{
OAuth2Authenticator auth = null;
try
{
var activity = this.Context as Activity;
if (CrossConnectivity.Current.IsConnected)
{
auth = new OAuth2Authenticator(
clientId: AppConfiguration.clientId,
scope: "",
authorizeUrl: new Uri(AppConfiguration.authEndPointURL),
redirectUrl: new Uri(AppConfiguration.redirectUri));
auth.ClearCookiesBeforeLogin = true;
auth.AllowCancel = false;
auth.ShowErrors = true;

                auth.Completed += async (sender, eventArgs) =>
                {
                    if (eventArgs.IsAuthenticated)
                    {
                        var accessToken = eventArgs.Account.Properties["access_token"];
                        var refreshToken = eventArgs.Account.Properties["refresh_token"];
                        await SecureStorage.SetAsync("oauth_token", accessToken);
                        await SecureStorage.SetAsync("oauth_RefreshToken", refreshToken);
                        AppConfig.SaveSFParameters(LandingPage.userId, LandingPage.orderId, LandingPage.sourceOfInvocation, LandingPage.uniqueId, "true", LandingPage.relatedId, LandingPage.patientInitials, LandingPage.patientDOB);
                        MessagingCenter.Send<string>("", "NavToScanPage");
                    }
                };
            }
            else
            {
                Console.WriteLine("Not Authorised");
                return;
            }
            global::Android.Content.Intent ui_object = auth.GetUI(activity);
            activity.StartActivity(ui_object);

Steps to reproduce

Platform:

  • [] .NET version = 6.0.301
  • [] mono version = 6.12.0.182

Expected behaviour

On Allow Access click the screen should be dismissed and user should be redirected to the App.
Allow access click does not come back on completed event.
Tell us what should happen

Actual behaviour

On Allow Access click the user stays on the Allow Screen and not redirected back to the App.
Tell us what happens instead
Can you also include a screen shot?

IF IT IS A NEW FEATURE REQUEST, INCLUDE THIS PART:

Feature description

The User is authenticated using oAuth2. After Login user is redirected to the Mobile App.
Include some graphics if this could help!

@mannawar
Copy link

Can you check the following:-

  1. Redirect url is set correct or not?. Check your oauth2 client id and secret for mobile app.
  2. check the callback url configured in the salesforce app matches with the url being used in the mobile app

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

No branches or pull requests

2 participants