Obtain user profile picture/badge for the signed-in google user - javascript

My web application uses google user-id for authentication. How do I fetch the currently signed-in user's profile picture/badge in javascript?
Note: I only have the access to the user's email address and id. I don't have the profile id.

Sounds like you're using the Users API, which doesn't offer access to profile info: Access to user's name and profile picture in the AppEngine's app.
Depending on which kind of users your app is dealing with (any gmail user, Google Apps users, Google+ users, etc) using other APIs could be attempted instead: Google+ API, Directory API, etc.
Another possibility would be switching to some other authentication method offering access to profile info. See What is the difference between Google identity toolkit, Google OAauth and Google+ sign in

Related

Adding Google Sign-In To Web App & Retrieve Group Membership From GSuite?

For an internal web app I'm developing in Python/Django I need to retrieve the user's group membership from GSuite and grant/deny the user access to specific webpages depending on what group they have access to.
I've read about how to add a Google Sign-in button, which works as expected: https://developers.google.com/identity/sign-in/web/sign-in
However, the user's basic profile doesn't give me the group memberships. I've checked this documentation page (https://developers.google.com/identity/sign-in/web/reference#googleusergetbasicprofile) but can't see any reference to group memberships.
Does that therefore mean I need to connect to the GSuite Admin SDK? If so, can I grant a service account read-only permission to retrieve the group memberships?
Reading this (https://developers.google.com/admin-sdk/directory/v1/guides/delegation) and the 0Auth 2.0 authorisation scopes (https://developers.google.com/identity/protocols/oauth2/scopes#admin-directory) seems to suggest I can only grant the service account domain-wide access to administer GSuite Users, which would be a security concern.
After speaking with Google Support, they suggest to use the Groups API here:
https://cloud.google.com/identity/docs/how-to/query-memberships#python_1

Accessing google anyaltics API in my aaplication

I am currently working with the Google Analytics API. I have implemented ga react package, so the analytics tool can show me the required data.
As per my understanding, Google uses OAuth 2.0 to identify the user and grant access. As my application has it's own user(s) and every user is not available in google.
Is it possible to access the Google analytics API inside my application?. API should get called using an only the API key.
So is it possible to access Google analytics API with the only key?
First off let me start by saying im not sure i understand this statement
As my application has it's own user(s) and every user is not available in google.
I am going to assume that you are trying to show the users of your application the analytics data from a single analytics account which they dont have access to.
API Keys
Api keys are used to access public data only. Public data is data that is not owned by any user. Public Videos on YouTube, Google analytics meta data API, Holiday calendars on google calendar these are all examples of Public data not owned by any user.
Private data
In order to access private user data you must have the permission of the user who has access to that data. Google analytics data is private user data you own the data associated with your account. In order for your application to access that data it must have your permission to do so. Permission is grated using Oauth2.
If you will only ever be accessing your own account and you will not be accessing data owned by other users then you could consider using a service account. Service accounts are dummy users you can share your google analytics account with the service account there by preauthorizing its access and it will then be able to access the data without needing to be logged in all the time. The issue with service accounts is that it cant be used client side you will need to use server sided code for this. I am not a react developer so im not sure if thats one of the JavaScript frameworks that can also run server-sided or not.

Google drive and Firebase Google auth info ionic

I have an app with google auth configured with firebase. can I use the token generated by firebase to access google drive documents?
I want the user logged in inside the app with Gmail auth to be able to read a document on Google drive that is shared with him.
I can't find anything online about this case.
I tried to open the document inside a webview but ask me to login to google drive
you have to follow these steps in order to make Google Sign-In and access to drive work.
Go to your credentials
Choose OAuth consent screen
Fill all the required details
Choose OAuth client id
Fill all the required details and For SHA1 key use this ‘keytool -exportcert -keystore ~/.android/debug.keystore -list -v’
Copy Client Id & use as reverse client id
NOTE image Android
Good Example
https://www.jellyfishtechnologies.com/blog/implement-google-drive-api-ionic-2/

Use Linkedin API to retrieve my profile info

I am developing my personal website and I want to retrieve my profile info on my Linkedin account by using the Linkedin API, so whenever I update on Linkedin, my personal website will be updated automatically as well. But this service needs to gain the OAUth2 token by logging in. How I can login (or gain OAuth2 token) from code-behind with my username and password, instead of manually login every-time? Prefer using JavaScript (client-side) or Python (server-side)
It looks like you need to use your username and password to obtain an Authentication key with LinkedIn. After authenticating yourself, you should be able to work with the API.
You can find information on how to do this here (link)

Using Google sign in api - manage users permission

I understand that I can use Google Sign in button and grant access to my website only to users from my domain (using metadata tag).
My question is, once a user is logged in can I control the pages that he/she sees. For example I want some users to be admins but other users to be regular users. Each user 'type' will have access to different set of pages.
Thanks,
Shay
Google's sign-in API can only authenticate users, it can't manage authorizations. For that you'll need to either use a cloud service like Cognito (which supports Google sign-in as a federated login provider for its own temporarily-generated identity) or write your own server-side access manager that associates the sign-in token with specific permissions, and then handles the authorization of user requests.

Categories

Resources