H
H
Habr2020-07-04 19:07:55
JavaScript
Habr, 2020-07-04 19:07:55

How to open oAuth authorization window and catch parameters from URL?

In native JS, this function works

let win = window.open('oauthURL', 'oauth', 'width=800,height=600,status=0,toolbar=0');
    let timer = setInterval(function () {
        try {
            let path = win.location.pathname.split('/')
            if (path[1] === 'oauth-success') {
                clearInterval(timer)
                win.close()
                // SUCCESS CALLBACK
            }
            if (win.closed) {
                clearInterval(timer)
            }
            return false;
        } catch (e) {
            // ERR CALLBACK
        }
    }, 1000);

Is there an analogue of the same function for React Native?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2020-07-04
@RozmarinUS

This is not a bad example. https://dev.to/safaiyeh/react-native-authenticatio...
you need to use a webview to login. be sure to use https://github.com/react-native-community/react-na... and be sure to use the latest version otherwise there will be issues when publishing to the Apple Store.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question