Skip to content

IOS Authorize error State mismatch, expecting #591

@vprtsingh

Description

@vprtsingh

Issue

It Working fine on android. But not for IOS

My Code

import React, { Component } from "react";
import { View, Text, Platform } from 'react-native';
import { authorize } from 'react-native-app-auth';

class MyComponent extends Component {

    _signInAsync = async () => {
        try {

            const config = {
                clientId: "xxxxx",
                redirectUrl: Platform.OS === 'ios' ? 'urn:ietf:wg:oauth:2.0:oob' : 'com.wildhire.app://react-native-auth',
                scopes: ['openid','offline_access','profile','User.Read','Calendars.ReadWrite'],
                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',
                }
            };

            const result = await authorize(config);

            console.log('success result =>', result)

        } catch (error) {
            console.log('error =>', error)
        }
    };


    render() {
        return (
            <View>
                <Text onPress={this._signInAsync} >SignIn Sync </Text>
            </View>
        )
    }
}

export default MyComponent

Error

error => Error: State mismatch, expecting lEjlyD_Y0Hogp9IqsnmzFixuItdxQ5guvtqlWFY3Ano but got (null) in authorization response <OIDAuthorizationResponse: 0x60000149d770, authorizationCode: (null), state: "(null)", accessToken: "(null)", accessTokenExpirationDate: (null), tokenType: (null), idToken: "(null)", scope: "(null)", additionalParameters: {
}, request: <OIDAuthorizationRequest: 0x600001cdb560, request: https://login.microsoftonline.com/common/oauth2/v2.0/authorize?prompt=select_account&nonce=9Ik43IE3P6ng18RtDPoLDUHfgei7RZubWvqR63ZZii0&response_type=code&code_challenge_method=S256&scope=openid%20offline_access%20profile%20User.Read%20Calendars.ReadWrite&code_challenge=oOGQVMW_myhXbV72cxXVPwqM6jOuC3Ws1EWNZW6ha4w&redirect_uri=urn:ietf:wg:oauth:2.0:oob&client_id=917f260d-6261-4bd9-bbd7-f51a08ed46c0&state=lEjlyD_Y0Hogp9IqsnmzFixuItdxQ5guvtqlWFY3Ano>>
    at Object.fn [as authorize] (NativeModules.js:99)
    at authorize (index.js:187)
    at _callee$ (VM5 CalendarSync.bundle:71)
    at tryCatch (runtime.js:63)
    at Generator.invoke [as _invoke] (runtime.js:293)
    at Generator.next (runtime.js:118)
    at tryCatch (runtime.js:63)
    at invoke (runtime.js:154)
    at runtime.js:189
    at tryCallTwo (core.js:45)

Environment

  • "react": "16.9.0"
  • "react-native": "0.61.5"
  • "react-native-app-auth": "^5.1.2"

Anyone help me as soon as possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions