0

I'm using react-native-app-auth package to do my sign in process with MS Graph API. The problem that I face here is,

When we do the login using,

import { authorize } from 'react-native-app-auth';

const config = {
  issuer: '<YOUR_ISSUER_URL>',
  clientId: '<YOUR_CLIENT_ID>',
  redirectUrl: '<YOUR_REDIRECT_URL>',
  scopes: ['<YOUR_SCOPES_ARRAY>'],
};

const result = await authorize(config);

And this opens the MS Authentication page in an in-app browser(from the react native app) and there it asks for username/password and does the authorization and returns back to the app(react native) with the access token.

Problem: When I open the safari browser and open office.com or outlook.com and click on sign in it automatically takes to the home page without asking for credentials.

But we don't want this to happen. Any idea to prevent or sort this out?

Thanks in advance.

Regards, RJ

2 Answers 2

0

You can try using Oauth authentication to login for react native app , sample code , if you want to know more , please check - https://github.com/microsoftgraph/msgraph-training-react-native

import AsyncStorage from '@react-native-async-storage/async-storage';
import {authorize, refresh, AuthConfiguration} from 'react-native-app-auth';
import moment from 'moment';

import {AuthConfig} from './AuthConfig';

const config: AuthConfiguration = {
  clientId: AuthConfig.appId,
  redirectUrl: 'graph-tutorial://react-native-auth/',
  scopes: AuthConfig.appScopes,
  additionalParameters: {prompt: 'select_account'},
  serviceConfiguration: {
    authorizationEndpoint:
      'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
    tokenEndpoint: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
  },
};
Sign up to request clarification or add additional context in comments.

8 Comments

Thanks for the response. But it would be great if we can suggest some for react-native.
Apologize for that i given react code , add code for react native please check my updated ans above. Hope this will help , thanks .
Thanks for the response. But this code helps to select account during login in app, but the actual issue that i mention here is, Once I do the login in the app and close the app. Open the device default browser(safari or chrome) and hit office.com, it directly opens the home page and not asking for login.
As you can see the authorizationEndpoint in my above code , when you add that in your code , it will redirect you the the login page , once you login you will get the token , which will add in tokenEndpoint , could you please try above code once , hope that will work. Thanks
I would like to give a more elaborate description of the issue. The config that you have given is the one that I'm using as well. But the issue that I face is once the login is done using the react-native app. I open the normal browser and hit office.com it automatically redirects me to the home page without asking for credentials in the browser which is what my issue is.
|
0

After a struggle was able to understand that, as per the latest updates on security SSO is made mandatory where if we use the default browser or system browser it will store the cookies and make our login when we open the browser it automatically does the login.

1 Comment

SO does it mean that we need to use logout endpoint instead of using incognito browser tab?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.