Firebase-Authentication error in objects 'mAuth' and 'mCallbacks' - firebase

the mAuth and mCallbacks object is giving red-font-error. How to resolve this?
Do I need to make the object outside of the codeblock?
here is the code block in which the red-font errors are showing up:
PhoneAuthOptions options =
PhoneAuthOptions.newBuilder(mAuth)
.setPhoneNumber(phoneNumber) // Phone number to verify
.setTimeout(60L, TimeUnit.SECONDS) // Timeout and unit
.setActivity(this) // Activity (for callback binding)
.setCallbacks(mCallbacks) // OnVerificationStateChangedCallbacks
.build();
PhoneAuthProvider.verifyPhoneNumber(options);

If you keep following the documentation on implementing phone authentication on Android, you'll see that the mCallbacks object is defined in the next step, right under the code you have above. It is explained as:
When you call PhoneAuthProvider.verifyPhoneNumber, you must also provide an instance ofOnVerificationStateChangedCallbacks, which contains implementations of the callback functions that handle the results of the request.
Under that explanation is a code sample, and then an explanation of each individual callback and its purpose.
I recommend reading the entire page first, so that you understand the complete flow, and only then starting to copy/paste the relevant code snippets.

Related

Axon - How to get #QueryHandler handle method to return an Optional<MyType>

Note:
The point of this question is not to just getting back a value that I ultimately want.
I can do that by simply not using Optional.
I would like an elegant solution so I could start returning Optional.
Explanation of what I tried to do:
I used the QueryGateway with a signature that will query my handler.
I broke out my code so you can see that on my CompletableFuture I will do a blocking get in order to retrieve the Optional that contains the object I really want.
Note that I am not looking for a class that holds my optional.
If this is not elegant then I may as well just do my null check.
The call to the query works, but I get the following error:
org.axonframework.axonserver.connector.query.AxonServerQueryDispatchException: CANCELLED: HTTP/2 error code: CANCEL
Received Rst Stream
AXONIQ-5002
58484#DESKTOP-CK6HLMM
Example of code that initiates the query:
UserProfileOptionByUserQuery q = new UserProfileOptionByUserQuery(userId);
CompletableFuture<Optional<UserProfile>> query =
queryGateway.query(q,ResponseTypes.optionalInstanceOf(UserProfile.class));
Optional<UserProfile> optional = query.get();
Error occurs on the query.get() invocation.
Example of my Query Handler:
#QueryHandler
Optional<UserProfile> handle(UserProfileOptionByUserQuery query, #MetaDataValue(USER_INFO) UserInfo userInfo) {
assertUserCanQuery(query, userInfo);
return userProfileRepository.findById(query.getUserId());
}
The query handler works fine.
Other efforts such as using OptionalResponseType would not initiate my query as desired.
I think the key lies with the exception you are receiving Stephen.
Just to verify for my own good, I've tested the following permutations when it comes to Optional query handling:
Query Handler returns Optional, Query Dispatcher uses OptionalResponeType
Query Handler returns MyType, Query Dispatcher uses OptionalResponeType
Query Handler returns Optional, Query Dispatcher uses InstanceResponeType
Added, I've tried out these permutations both with the SimpleQueryBus and Axon Server. Both buses on all three options worked completely fine for me.
This suggest to me that you should dive in to the AxonServerQueryDispatchException you are receiving.
Hence, I am going to give you a couple of follow up questions to further deduce what the problem is. I'd suggest to update you original question with the response(s) to them.
Do you have a more detailed stack trace per chance?
And, what versions of Axon Framework and Axon Server are you using?
Are you on the Standard Edition? Enterprise edition?
Does this behavior only happen for this exact Optional query handler you've shared with us?

Can Xamarin UITest backdoors return a value on iOS?

I'm writing automated tests for a Xamarin Forms mobile app. Since it's difficult to directly interact with an embedded Google/Apple map, I wrote a few backdoor methods designed to get all the information the map would provide to a human. However, on iOS, the method I wrote doesn't provide a return value, despite my instructions to the contrary.
So far, I've done all manner of things, including reducing the method to nothing but a stub returning a dummy string. It still refuses to do it. Nowhere in Microsoft's documentation indicates that a value can't be returned on iOS.
[Export("GetUnits:")]
public NSString GetUnits(NSString val) // param unused
{
return new NSString("TEST"); // returns this value in the app, but it doesn't ever make it to the test harness
}
The above code should return "TEST" to the test harness, which would then be printed in my REPL after I call app.Invoke("GetUnits:", ""), which always produces
[
]
instead of
[
"TEST"
]
The method is named properly and called properly; error messages occur if I don't call it properly (e.g. wrong number of parameters, wrong method name) and test code inserted into the method executes fine, so I know it's executing. It's just not returning the value to the test harness. The equivalent Android version of this method works perfectly.
I found one person on the Xamarin forums with the same problem, but his topic hasn't been touched in two years. I've read every pertinent thing I can find on the web, all to no avail.
Edited for formatting. (Whoops.)
Here's what we're using in our own integration tests to make sure we don't break this functionality:
This line is how we're calling the backdoor:
_app.Invoke("backdoorWithString:", stringArg).ToString().ShouldEqual(stringArg);
And in the app, the backdoor we're referencing is defined in a native app, so it's hard to compare:
- (NSString *) backdoorWithString:(NSString *) value {
I would advise changing your Export to the correct casing:
[Export("getUnits:")]
Also please check that this method is in your AppDelegate.cs file.

Cloud Endpoints - Google Glass object has no attribute 'mirror_service'

I'm attempting to incorporate cloud enpoints into my app, I'm currently using the Python Quickstart for proof of concept. I'm having an issue when I attempt to call a method to send a card to my glass. Below is my code, please ignore the indentation is missing.
#endpoints.api(name='tasks', version='v1',
description='API for TaskAlert Management',
allowed_client_ids=[CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID])
class TaskAlertApi(remote.Service):
#endpoints.method(Task, Task,
name='task.insert',
path='tasker',
http_method='POST')
def insert_task(self, request):
TaskModel(author=request.author, content=request.content, date=request.date).put()
themirror = MainHandler()
themirror._insert_map_with_distance_from_home()
return request
So when "themirror._insert_map_with_distance_from_home()" is called I am getting the following error. Does anyone have any suggestions? I am trying to call this from myappspot.com/_ah/api/explorer.
in _insert_map_with_distance_from_home
self.mirror_service.timeline().insert(body=body).execute()
AttributeError: 'MainHandler' object has no attribute 'mirror_service'
I'm afraid you will have to rethink your code quite a bit for this but I'll try to get the basics explained here.
The main problem is that the MainHandler does quite a bit when actually receiving a HTTP request. The most important thing is what happens in the #util.auth_required decorator of the MainHandler's get method, which actually creates the mirror_service, authenticated for the current user. When you access the MainHandler directly from your code, none of this actually happens, so there is no mirror_service available (which results in the error you get).
Since the way endpoints are called is quite different from the way normal RequestHandlers are called, you also can't rely on stored session credentials or similar to match an Endpoints User to the Mirror User.
Basically what you would have to do is to create a new mirror_service inside of your endpoint method.
For this you will have to call your API authenticated (adding the Mirror API scopes to the authentication scopes). You can then extract the used access_token from the request header and use this access_token to create OAuth2Credentials to create the mirror_service.
Some code snippets without promises of completeness since it's hard to tell without knowing your actual code:
import os
from oauth2client.client import AccessTokenCredentials
# extract the token from request
if "HTTP_AUTHORIZATION" in os.environ:
(tokentype, token) = os.environ["HTTP_AUTHORIZATION"].split(" ")
# create simple OAuth2Credentials using the token
credentials = AccessTokenCredentials(token, 'my-user-agent/1.0')
# create mirror_service (using the method from util.py from the quickstart(
mirror_service = create_service('mirror', 'v1', credentials)
Of course you would then also have to change the _insert_map_with_distance_from_home to use this mirror_service object, but moving this method away from your MainHandler would make more sense in this context anyway.

Can the callback parameter in FirebaseAuthClient take a context parameter?

I see that the on method of a Firebase ref can take a context parameter that is this within the context of the callback. This is incredibly useful. I am wondering -- and hoping -- that the callback function that is provided to FirebaseAuthClient can also take a callback, but my intense scrutiny of the Examples, Getting Started and SDK documentation reveal no mention of it. I attempted to scour the minified firebase-auth-client.js but stopped with my sanity still intact.
A related question: FirebaseAuthClient does not seem to be included in the JavaScript SDK area. Is it anywhere?
[Engineer at Firebase]
The Firebase Simple Login constructor now accepts a context argument as its third argument. For example, to have your Simple Login callback invoked with myContextObj as its context:
var ref = new Firebase('https://<my-firebase>.firebaseio.com');
var simpleLogin = new FirebaseSimpleLogin(ref, function(error, user) { ... }, myContextObj);

PopUpWindow and null object reference

I've been struggling with this problem for last few hours but still got no idea what's wrong. Here's the scenario:
Application built on top of the Mate framework sometimes need to exchange data with remote server over plain binary socket.
When specific packet is received I have to switch view (using ViewStack) and create custom panel (using PopUpManager class). This custom panel contains a dataGrid component which has to be populated with some XML received along with mentioned packet.
Trouble is that when I try to assign XML to DataGrid's dataProvider I constantly get "Cannot access a property or method of a null object reference" error. The only thing I can think of is some kind of race when processing events and creating components.
Here are the most interesting pieces of code:
<!-- LoginEvent.LOGIN_OK _____________________________________________________________________ -->
<EventHandlers type="{LoginEvent.LOGIN_OK}">
<MethodInvoker generator="{UserManager}" method="storeCurrentUser" arguments="{event.fullName}"/>
<EventAnnouncer generator="{NavigationEvent}" type="{NavigationEvent.MAIN}"/>
<MethodInvoker generator="{CustomSocket}" method="listBoards"/>
In the above code I react when the LOGIN_OK packet is received.
Store user's data, change the view and ask the Socket class wrapper to send request (the reponse for that request is our verySpecificPacket)
Here's detailed info about how I change the view and create custom pop up. In MainUI.mxml:
<mate:Listener type="{NavigationEvent.MAIN}" method="handleNavigationEvent" />
private function launchBoardListWindow():void {
Logger.info("launchBoardListWindow()");
var win:BoardList = PopUpManager.createPopUp(this, BoardList, true) as BoardList;
PopUpManager.centerPopUp(win);
}
private function handleNavigationEvent(event:NavigationEvent):void {
viewStack.selectedIndex = MAIN;
launchBoardListWindow();
}
The third position in EventMap isn't important, it just ask socket wrapper to send some kind of packet. The server is supposed to respond with verySpecialPacket along with XML payload. And here we are at the part where the error is. In mxml describing my custom panel I set up a listener for an event which is being dispatched after my verySpecialPacket is received.
public function handleListBoardsEvent(e:ListBoardsEvent):void {
Logger.info("handleListBoardsEvent");
xmlData = e.xml;
boardList.dataProvider = xmlData.children(); // Here's the error!!!
}
I really don't get it, since the xmlData is OK, and custom panel with all child components were created. Thanks for reading!
You're likely on the right track in respect of a race condition.
Suggestion:
Put a try { ... } catch (e:Error) { trace("error"); } block around the code in your handleListBoardsEvent() method.
Then, put a breakpoint on the trace() and, when it hits, take a good look around at the various objects involved.
My guess is that you're attempting to access the boardList object before it is created - i.e. it's null.
The other possibility is that boardList.dataProvider is a setter and there's code in the setter that's barfing. (Although, if that were the case, I'm sure you would have noticed the stacktrace inFlexBuilder)

Resources