Android - Youtube Data Api - Get user permission without having to catch GoogleAuthIOException - android

I want to use the Youtube Data API.So i show an Account Picker dialog, get an email id, and then i want to access account-specific data from the user's Youtube account.
According to the docs, it seems that the first time any API call is made, GoogleAuthIOException will be thrown,and then you have to catch it, and get permission from the user.
However, is there a way to trigger the permission dialog without having to catchGoogleAuthIOException ? Like, can my app ask for permission just after i get the email id from the picker?

Related

Logout from Spotify with the sdk spotify-android-auth

I have an Android app, which the user can link to Spotify, with :
AuthenticationClient.openLoginActivity(getActivity(), SPOTIFY_REQUEST_CODE, request);
The problem is that I want the user to change his Spotify account so I want to logout the user from Spotify to log with another account. But the data of the connection are saved in the cache and when I use this line again :
"AuthenticationClient.openLoginActivity(getActivity(), SPOTIFY_REQUEST_CODE, request);", it does not show the connection dialog because the user is already connected.
In the doc, it says :
"To log out and clear all stored tokens, use the AuthenticationClient#clearCookies method. Both Spotify and Facebook tokens will be removed."
But the method clearCookies does not exist anymore. What can I do to logout the user and allow him to connect on another account ?
I've searched on the net and seems that this code
AuthenticationRequest.Builder builder = new AuthenticationRequest.Builder(CLIENT_ID, type, redirectUri)
.setShowDialog(true)
.setScopes(scopes).build();
took from this post it's your only choice to try to logout a user.
I can't test it, so you should try it yourself and see if works.
The documentation on the Spotify Android SDK is outdated and is not reflecting the new Spotify auth library on GitHub.
Spotify's Android SDK documentation is definitely outdated. My observation is that when you call
AuthorizationClient.clearCookies(context)
directly before starting Spotify's auth activity, it just works fine. But if you call it once and then expect that the user is logged out, when you start the activity later in the future, cached credentials keep messing around.
I do not prefer
builder.setScopes(arrayOf("")).setShowDialog(false).build()
as it shows you a "not you? Click to log out" option. So basically you need to log out on the Spotify UI, cannot do it from code.
In my case, the application saves the logged in user's email (I need that to show on the UI, anyway). When I want to log the user out programmatically, I just delete the saved email from the app and call
clearCookies()
when I start Spotify's Activity if the variable is empty.
A bit late, but you can use this AuthorizationClient.clearCookies(this) as
AuthenticationClient no longer exists

Smart Lock SDK is not retrieving credential sets correctly for NexusPlayer( Android TV )

Im currently setting up smart lock for our tv app in nexus player.
The problem is that even though i already saved few credential sets for my google account through our mobile app( which implemented the smart lock sdk long ago ), i cant retrieve all of them in our tv app.
in our Tv app , i can only retrieve one of those credentials.
And whats even stranger is that if i try to save my one of my credentials through my tv app, which is already existing in the cloud ( the account begins with 6249) , it will be saved and you can see duplicated credentials . And after that i can retrieve this credentials from smart lock in the tv app.
Noted that the app's domain is the same for both tv app and our mobile app.
You can retrieve saved credentials through CredentialsApi.request() method.
Auth.CredentialsApi.request(mCredentialsClient, mCredentialRequest).setResultCallback(
new ResultCallback<CredentialRequestResult>() {
#Override
public void onResult(CredentialRequestResult credentialRequestResult) {
if (credentialRequestResult.getStatus().isSuccess()) {
// See "Handle successful credential requests"
onCredentialRetrieved(credentialRequestResult.getCredential());
} else {
// See "Handle unsuccessful and incomplete credential requests"
resolveResult(credentialRequestResult.getStatus());
}
}
});
Handle multiple saved credentials:
When user input is required to select a credential, the getStatusCode() method returns RESOLUTION_REQUIRED. In this case, call the status object's startResolutionForResult() method to prompt the user to choose an account. Then, retrieve the user's chosen credentials from the activity's onActivityResult() method by passing Credential.EXTRA_KEY to the getParcelableExtra() method.
Here's a documentation how to Store credentials: https://developers.google.com/identity/smartlock-passwords/android/store-credentials#store_credentials

CCA: Chrome identity pops up Account Chooser every time

I am making a Chrome/Android/iOS app using the cca toolchain. I am using the chrome.identity API to get an access_token to interact with Google APIs.
When I set interactive to false (immediate to true) the app is able to get the token without showing the permissions dialog again, but it still shows the account chooser every time on my Android device. This ruins the app experience because every time it is opened the user gets an annoying dialog. How can I make the app remember the chosen account after the first time, like it does with the permissions?
On Android, you can specify accountHint in the details argument of calls to getAuthToken. For example:
var details = { interactive: true, accountHint: 'email#address.com' };
var callback = function(token, account) { ... };
chrome.identity.getAuthToken(details, callback);
This will bypass the account chooser dialog. Note that the callback has account, which can be stored for this purpose.
Unfortunately, this is Android-only; Chrome on desktop doesn't like it when you add extra stuff to details. You'll need to use chrome.runtime.getPlatformInfo to determine what platform you're running on, so that you can create and pass the right details object. On Android, platformInfo.os will be cordova-android.

how to get location-id of instagram api in android

I am making one android application related to instagram so that I read all instagram developer apis after that i tried first user authentication it is working fine I am accessing user data by user-id api.Now i want location information for that i need location-id.I don't know where will i get
with user-id:
https://api.instagram.com/v1/users/**userid**/?access_token=13145898924.f59def8.f14ee72f42f14bea9f56d6dc96924483
with location-id:
https://api.instagram.com/v1/locations/location-id?access_token=13145898924.f59def8.f14ee72f42f14bea9f56d6dc96924483
in first url I got userid and I am retrieving information
in second url i don't know location-id please help me
1: First use facebook graph API to search locations and get facebook_places_id. Here is an example:
https://graph.facebook.com/search?q=&type=place&center=37.77493,-122.419415&distance=5000&access_token=ACCESS-TOKEN&expires_in=5184000
Get the facebook_places_id and use this instagram location search API to get the corresponding instagram_location_id
https//:api.instagram.com/v1/locations/search?facebook_places_id=273471170716&access_token=ACCESS-TOKEN
2: Get the location id and then make the instagram location media API to get recent media:
https://api.instagram.com/v1/locations/514276/media/recent?access_token=ACCESS-TOKEN
3: Here is an implementation of Instagram location media search using the above method:

How to get a friends user wall from facebook?

I want to read my friends posts (feeds?, all posts but for a specific user only) from his user wall.
I need all (posts, feeds, statuses) that i see when i look at his page directly from the website.
I use the android sdk and i tried the graph api and rest method.
My app is registered and i have logged in facebook to get the access token (permission: read_stream)
but i dont get that infos that want to.
Please help.
Thx.
How about testing your Graph API call in the Graph API Explorer?
https://developers.facebook.com/tools/explorer/
In my case, I could get my first 10 friends' feed (wall) with the url https://graph.facebook.com/me?fields=friends.limit(10).fields(feed)
Note that I used field expansion of the Graph API.
http://developers.facebook.com/docs/reference/api/field_expansion/
You need them to actually use your app and grant full permissions via the graph API.
You cannot simply 'grab a friends wall'. You must do that via your app and it needs the permissions to do so from the user in question.

Categories

Resources