question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"authorization" works but doesn't return anything

See original GitHub issue

Issue

I’ve got “authorize” to work against the Coinbase API. It authorizes and I get an email from then to say my app has been associated with my account. I also get redirected back to my app using Deep Linking.

The problem is “authorize” doesn’t return anything. I would have expected to receive something?

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

authorize() {
    authorize(config)
    .then(response => {
        console.log(response);
    })
    .catch(error => {
        console.log(error);
    });
}

I have also tried this but it doesn’t return anything either:

authorize = async () => {
    try {
        const authState = await authorize(config);
        console.log(authState);
    } catch (error) {
        console.log(error);
    }
};

The only time I see any feedback is if I cancel before it is authorized. Then it says the user has cancelled but if it is successful I get no feedback after returning to the app except for the email from Coinbase saying it was successful.


Environment

  • Your Identity Provider: Coinbase
  • Platform that you’re experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • Are you using Expo, e.g. ExpoKit?
    • No
    • Yes, I’ve not ejected
    • Yes, but I have ejected to ExpoKit
    • Yes, but I have ejected to vanilla React Native

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:32 (8 by maintainers)

github_iconTop GitHub Comments

8reactions
boris-etingof-flarehrcommented, Oct 20, 2021

I can confirm, with Azure B2C authorize promise doesn’t get resolved. No exceptions cought. No error logs running this from Xcode. Authentication modal comes up, I can enter the mobile number for TOTP, then enter TOTP code, modal closes but the promise returned by authorize doesn’t get resolved.

UPDATE: In my case redirectUrl value msauth.com.company.app://auth was missing trailing forward slash. That resulted to shouldHandleURL in OIDAuthorizationService.m to return false negative as @mion mentioned. Adding / fixed the issue.

await authorize({
      clientId: 'xxx-xxx-xxx-xxx-xxx',
      redirectUrl: 'msauth.com.company.app://auth/', <--- Added `/` here
      scopes: ['openid', 'offline_access'],
      serviceConfiguration: {
         authorizationEndpoint: `${baseUrl}/authorize`,
         tokenEndpoint: `${baseUrl}/token`,
      },
});
3reactions
mioncommented, May 8, 2019

@whittlem I was having the exact same issue and I’m using the same approach of having an HTML page redirect to a custom URI (such as foo://auth).

I just tried the update from @pbfrias17 answer and it works! Comment out OIDAuthorizationService.m line 113 and run it again, it should return now. The problem is here in line 113:

  if (![self shouldHandleURL:URL]) {
    return NO;
  }

The problem is that the custom URI that the app receives through deep linking is not the same as the one it was configured with (the one starting with https), and this check returns NO.

Other than this ugly fix, I guess the alternative is to use Universal Links. It would be nice to see some mention of this in the docs because I think lots of people would try this approach before turning to Universal Links.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why don't my unauthorized controllers return 401 ASP.Net ...
When I access do a controller with "Authorize" attribute, it should return a 401 request but it doesn't return anything in postman.
Read more >
Alter Authorization method doesn't seem to do anything and ...
I attempted to use the code below to change the ownership from Domain1/SvcAcct1 to dbo. It acts like it runs successfully, but as...
Read more >
Troubleshooting | Search Ads 360 API - Google Developers
If you run into problems while using the Search Ads 360 API, take a look through this troubleshooting section. If there's a problem...
Read more >
What Is Token-Based Authentication? - Okta
But what are auth tokens and how do authorization tokens work? ... which allows users to verify their identity, and in return receive...
Read more >
The Authorization Response - OAuth 2.0 Simplified
If there is something wrong with the syntax of the request, such as the redirect_uri or client_id is invalid, then it's important not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found