Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

A0LockReact.m delegationWithOptions passes null dictionary when attempting to obtain firebase token, crashing app #39

Closed
richardstephens opened this issue May 10, 2016 · 3 comments
Labels

Comments

@richardstephens
Copy link

Hi there,

If I attempt to obtain a firebase token through the Auth0 delegation API as such, my application crashes in native code.

    lock.delegation({
        token: token,
        api: "firebase"
      }, (a,b,c) => {
        console.log("delegation callback",a,b,c);
      });

The crash I see in the XCode console is as follows:


2016-05-10 16:20:18.465 TodoApp[25813:911468] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000112077d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000011126cdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000111f7423e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
    3   CoreFoundation                      0x0000000111f865bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
    4   TodoApp                             0x000000010e57e584 -[A0LockReact delegationWithOptions:callback:] + 1556
    5   TodoApp                             0x000000010e580fe4 __41-[A0LockReactModule delegation:callback:]_block_invoke + 84
    6   libdispatch.dylib                   0x0000000113a0fd9d _dispatch_call_block_and_release + 12
    7   libdispatch.dylib                   0x0000000113a303eb _dispatch_client_callout + 8
    8   libdispatch.dylib                   0x0000000113a181ef _dispatch_main_queue_callback_4CF + 1738
    9   CoreFoundation                      0x0000000111fd10f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    10  CoreFoundation                      0x0000000111f92b99 __CFRunLoopRun + 2073
    11  CoreFoundation                      0x0000000111f920f8 CFRunLoopRunSpecific + 488
    12  GraphicsServices                    0x000000011512cad2 GSEventRunModal + 161
    13  UIKit                               0x000000010f6f2f09 UIApplicationMain + 171
    14  TodoApp                             0x000000010e331daf main + 111
    15  libdyld.dylib                       0x0000000113a6492d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

After stepping through the code, it appears that this is because the scopeParamterFromOptions method returns a nil if no scope is provided.

Providing an empty string for the scope parameter prevents the crash:

      lock.delegation({
        token: token,
        api: "firebase",
        scope: ""
      }, (a,b,c) => {
        console.log("delegation callback",a,b,c);
      });

But this still doesn't work - Auth0 calls my callback with the error Request failed: bad request (400). I can't see any documentation for what should go in the scope parameter for a request for a firebase token.

@hzalaz hzalaz added the bug label May 10, 2016
@hzalaz
Copy link
Member

hzalaz commented May 10, 2016

Yes, I've merged a PR without properly checking it. Will fix that soon, can you try sending openid in the scope?

@richardstephens
Copy link
Author

Hi Hernan,

okay - no worries. We're supplying "openid name email" in the scope now and we get back a valid firebase token.

Another thing I noticed in that code that looks a bit off is this in the delegationWithOptions method:

    NSString *api = options[@"api"];
    if (!api) {
      api = @"app";
    }

But then the options map is referenced directly when the request parameters are created:

A0AuthParameters *parameters = [A0AuthParameters newWithDictionary:@{
                                                                         A0ParameterAPIType: options[@"api"],

Thanks for getting back to us so quickly.

-Richard

@hzalaz
Copy link
Member

hzalaz commented May 17, 2016

Should be fixed by #45. The method signature changed since now it will return a Promise

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

No branches or pull requests

2 participants