I am creating an app which is related to get the images from flickr but in this by passing user id we will get the images from a particular account with providing user id manually.
but i required the user id when user login with username and password.
how can get user id by passing username and password?
Your formulation is not really clear, but if what you are asking is how to get the user ID from the user name, since flickr uses OAuth; a quick look at the api documentation can give you the query you need to use:
lookupuser seems useful or
findbyusername
the first one gives you the id corresponding to an user url, the second one the id corresponding to an username.
You just have to parse the response to get the id (unless flickr provides a wrapper that does the parsing for you but it does not seem to be the case:)
Related
According to this guide the built-in authentication of FirebaseUI should already handle this. Indeed, retrieving the current user and calling currentUser.displayName (Kotlin here) the string returned is "Lamberto Basti" that is my name concatenated with my last name. Is there a smart way to retrieve them separately?
Notice that I've enabled login with email, Facebook, Google and Twitter.
There is no API to get the separate first name and last name from Firebase Authentication. If you need the name in that format, you will need to ask your user for them (potentially pre-populating the UI based on their display name).
Note that splitting the string on a space to get the first name and last name may work in your tests, but will likely lead to problems as you roll out internally. To learn more about the intricacies, I recommend reading the W3C treatise about personal names around the world.
I am developing a Firebase chat app.
I have implemented Firebase email/password authentication. So, when user signups successfully, I have a code through which on every signup/register the app stores user details like name,email, etc in Firebase database under uid node.
Then, the user searches for a friend using a email id,
if the uid with that email id is present in the firebase database, the function returns true,
then, the app, adds that email id under
<FirebaseApp>
<users>
....users details...
<friends>
<userid>
<unique pushed id> : searched email // here the friend's email id is added
After adding the new friend,
I am using a recyclerview to show the friend list.
So, the app retrieves all the nodes under friends>> current user's uid>>
As my database structure describes I have only saved friends uid in friends database.
At first step the user will have only friends' email ids. Let say in List friendsList.
Then I use this friendsList to retrieve all the other details of friends like profile picture, name, contact and etc... which is saved under users node.
But using for each loop retrieving the other details of every friend, and then store in a array list, then paasing that arrayList to adapter and then displaying to recyclerview. is a very time consuming process.
Becuase, it can have other functions too. like converting Base64 image to bitmap etc.
So every time activity starts , following all above steps, will make a lengthy process.
other that this, I have another way, where I can save friends other's details too under friends node. like name, contact etc. at a point when a new friend added to the database.
But again another question arises.
yes, I can store friend's other details too... But what if the friend updates his profile picture, contact?
So, this procedure is not suitable in my case.
How can I create a whatsapp like friends list in my Firebase app, where I every user's friends list will be always updated with his/her friends details.
also, the will not go under any lengthy process.
The best approach is to save all the necessary details in the friends node as well.
You can just save the Opposite_Friends tag in each user, where just add all the uids in whose friends list user is present, So that whenever user updates any detail, you can update it in every users Friends node as well.
I am developing a social network app that uses Parse.com as a back-end
I gave users the ability to change their name , email and profile picture (which is a parseFile)
And when users are logged in i gave them the ability to add posts
I add the posts by getting the user email and name by
ParseUser.getCurrentUser()
and saving the returned content to my ParseObject
but now the question is what if the user updated his data which is the profile picture or name or email how to update the post data dynamcly
You're going to have to write some cloud code. https://parse.com/docs/js/guide
I would create an beforeSave trigger for your users, check to see if the relevant fields are 'dirty' (have been changed), and, if they have been, create a new object of a customer class that just has a pointer to that user.
Save a pointer to the user on each post.
Create a background job that runs each day/hour/however often you want to do these updates that goes through all of your custom objects that contains a user, use Query.each() to go through each of those objects, and then do a query for all posts where the user key is equal to the user of the custom object. Then set the name/email fields as appropriate.
Make sure that when you're done, you delete all of the custom objects so that you don't continuously perform this job on more and more objects each time.
Alternatively, you could just add the user pointer to the post, and when you fetch your posts, include the user key, so that gets fetched as well. Then you can read the name/email directly from the user, which will always be dynamic. You have to make sure that your ACLs are set up so that users can't edit all of another user's info or something, though.
We associate every parse user to their facebook ID as in the documentation.
ParseFacebookUtils.link(user, this, new SaveCallback()
However how is it possible to query the objects of a facebook friend using his facebook ID in Parse SDK Android?
This is only possible if you store the relationship information in Parse by associating the information with the user record. Even though Parse stores the facebook ID in the authData column, it is not queryable there.
You can get the facebook ID from the Graph API after user logs in (link) and store it as an additional column on the user record in Parse. When the user adds a friend, store this relationship in a table of your making. You can query that table to determine what the friend IDs are and access the appropriate data.
Alternately, if these queries only need to run while the user is currently logged in, you don't have to store the friend relationships. You can query the graph API (/me/friends) to get a list of friends of the user that are using your app. Facebook guarantees that they will return the same user IDs to your app each time.
I am building an API in RoR to be used by an android app. I have looked at various other similar questions on SO but found nothing which fits my exact use case. I need to identify a logged in user and respond to the request accordingly. This goes just beyond getting the user id to user categories, implicit preferences (different from settings) to give the user a more personalized experience.
In a web app this is done through a session cookie using which I can essentially call the following methods:
current_user.id # Gets user's id
current_user.category # Gets user's category
current_user.auth_level #Gets user's permission level
To do this, in the webapp I have the following setup:
In login action:
...
#user_session = session_setter(email, password)
...
def session_setter(email,password)
#session = UserSession.new(:email => email, :password => password)
#session.save
end
UserSession.rb
class UserSession < Authlogic::Session::Base
logout_on_timeout true
last_request_at_threshold 100
skip_callback :persist, :persist_by_cookie
skip_callback :after_save, :save_cookie
skip_callback :after_destroy, :destroy_cookie
end
session_store.rb (configured for memcached)
require 'action_dispatch/middleware/session/dalli_store'
App::Application.config.session_store :dalli_store, :memcache_server => ['127.0.0.1:11211'], :key => '_session'
This setup allows me to access current_user object once the user is logged in and access all columns in the table users.
For android, this is what I have figured out:
Create an api_key for each user who creates an account. This could have an expiry date. Maintain and store this key in the users table. The api_key is passed on to the app on the first request where it is stored in something like sharedPreferences. Every request should carry the api_key to the server. Put filters on actions which require the user to be logged in, to check if the key is present or not.
Now, here is my question: In this setup I would need to retrieve the users record from the table (or store it in the memcached with the api_key as a key value pair) on every request through the filter.Is there a way to use something like current_user with the api?
In short I want to to replicate the same strategy for maintaining logged in users for the api as I have for the web app.
API is supposed to be unaware of your web-app contexts.
API is the classical stateless HTTP.
You ask it a question, it gives you answers. Albeit, from your web app's state and data, but it has no concern with what goes on at that end.
An API cannot, or rather, should not be coupled with the user logged in/ logged out state.
It is your webapp's responsibility to query the API with as much information it needs to reflect the logged in state.
Eg.,
If your API has a method get_recommendations,
it should ideally take in multiple args, to be able to handle all cases
logged out users, will make the query, wrt the page being viewed. As in, a matrix movie scene being viewed, should give other matrix scenes as reco's
logged in users, will make the query, wrt other aspects. As in, how many action videos has been viewed by this user, can be passed in as an arg.
The API endpoint should have the ability to handle both these scenarios seamlessly.
Make other calls to other methods if need be, to find out the current user's (identified by a user id key passed in) details.
So, from a design perspective, you should not pass in anything other than the fact that this request is for a signed in user with id = X.
Let your API handle everything else.
API is nothing but a special function/method.
Methods can do pretty much anything, as long as they remain true to their description / signature.