2 different Google Calendar Sample Codes - Which examples I should apply? - android

I go through 2 different Google Calendar code samples. After finished reading them, I am getting confused.
https://developers.google.com/google-apps/calendar/instantiate
They are using oAuth2?
They are using scope https://www.googleapis.com/auth/calendar. Is it because they are using oAuth2?
They required 2 API keys, clientId and clientSecret. Is it because they are using oAuth2?
They are using com.google.api.services.calendar.Calendar.
http://code.google.com/p/google-api-java-client/source/browse/calendar-android-sample/src/main/java/com/google/api/services/samples/calendar/android/CalendarSample.java?repo=samples
They are using ClientLogin?
The scope is cl? Is it because they are using ClientLogin?
They only require 1 simple API access key. Is it because they are using ClientLogin?
They are using com.google.api.services.calendar.model.Calendar. What is the difference with com.google.api.services.calendar.Calendar?
My target platform is on Android. Should I be using method from 1st example, or 2nd example?

The second example is using Android functionality of AccountManager which can access stored account information on an Android device. The AccountManager class will do the OAuth in the background, so that the developer doesn't need to. See previous question.

Related

Creating enrollment token gives back wrong QR code

I'm trying to provision a device with QR code method according to these documentations.
I'm using this Google collab quickstart guide to do so.
Right now, I'm stuck here:
enrollment_token = androidmanagement.enterprises().enrollmentTokens().create(
parent=enterprise_name,
body={
"policyName": policy_name,
"qrCode": "{'android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME': 'com.tmp.app.admin/.AdminReceiver','android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM': 'MUQ6NEQ6MDQ6NTY6M0E6ODA6Mzg6NEY6NUM6ODI6Qzk6NUY6MkM6QjA6RTk6RDc6QTM6RjI6NDg6NTA6QTQ6RjY6QTA6RjM6MTA6NUM6MzI6NkY6QkU6NUI6M0E6Qzk%3D','android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION':'https://myurl-stuff.com/link_part/my_app.apk','android.app.extra.PROVISIONING_SKIP_ENCRYPTION': false,'android.app.extra.PROVISIONING_WIFI_SSID': 'MY_WIFI_SSID','android.app.extra.PROVISIONING_WIFI_PASSWORD': 'my_wifi_password','android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE': 'WPA'}"
}
).execute()
json.dumps(enrollment_token, indent=2)
Whenever I run this code, the output is the following.
{\n "name": "enterprises/LC00y54m79/enrollmentTokens/UV4yLfxoyWSln7CArwtp7OJQiHH_Gvc76JttPa4-r48",\n "value": "ZBNWPOWHBQUPNLMBTNRU",\n "expirationTimestamp": "2023-02-06T12:43:34.634467Z",\n "policyName": "enterprises/LC00y54m79/policies/policy1",\n "qrCode": "{\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME\\":\\"com.google.android.apps.work.clouddpc/.receivers.CloudDeviceAdminReceiver\\",\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM\\":\\"I5YvS0O5hXY46mb01BlRjq4oJJGs2kuUcHvVkAPEXlg\\",\\"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION\\":\\"https://play.google.com/managed/downloadManagingApp?identifier=setup\\",\\"android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE\\":{\\"com.google.android.apps.work.clouddpc.EXTRA_ENROLLMENT_TOKEN\\":\\"ZBNWPOWHBQUPNLMBTNRU\\"}}"\n}
It is the default Google example and it does not contains my application, instead, it contains Google's official example app.
What am I doing here wrong?
EDIT:
I have syntax error with double quotes.
EDIT 2:
Also tried with starting and ending single quotes like:
'{"android.app.extra (...)
Also tried with starting and ending with triple quotes like in Google's previous example like here:
But still no luck.
The api either returns a syntax error or simple doesn't returns with my app/parameters in the qrCode, instead it replaces to their own example project.
EDIT 3:
Tried like this:
But with no success:
There are two ways to manage devices :
Provision a device with your own DPC : Your DPC is installed (referenced by an URL in the QR code). It fetches policies from your servers and applies them as a profile / device owner, without using any Google API (Android only).
Manage devices using Google Play EMM API. It is basically Google's layer on top of the Android API (but often called Android Management API, which is a bit confusing) : Your EMM console send policies to Google's servers. They are applied on the devices by Google's own DPC.
You are trying to mix the two approaches. It is no longer possible :
Android Enterprise is no longer accepting new registrations for custom device policy controllers (DPC) using the Google Play EMM API.
All new EMM solutions should now use Android Management API, which comes with its own DPC provided by Google.
The Google DPC is the com.google.android.apps.work.clouddpc you are seeing in the generated QR code.
If you want to use you own DPC, you need to use the json containing the android.app.extra.PROVISIONING* keys directly, without wrapping it in a Google token.
The content looks fine except the SSID has to be quoted, and the signature hash should not be percent encoded :
{
"android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.tmp.app.admin/.AdminReceiver",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "https://myurl-stuff.com/link_part/my_app.apk",
"android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "MUQ6NEQ6MDQ6NTY6M0E6ODA6Mzg6NEY6NUM6ODI6Qzk6NUY6MkM6QjA6RTk6RDc6QTM6RjI6NDg6NTA6QTQ6RjY6QTA6RjM6MTA6NUM6MzI6NkY6QkU6NUI6M0E6Qzk=",
"android.app.extra.PROVISIONING_SKIP_ENCRYPTION": false,
"android.app.extra.PROVISIONING_WIFI_PASSWORD": "my_wifi_password",
"android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE": "WPA",
"android.app.extra.PROVISIONING_WIFI_SSID": "\"MY_WIFI_SSID\""
}
You just have to generate a QR code containing this content (with any generator), and scan it with the device.
Unfortunately the provisioning process is not forgiving. If something is wrong, the device shows a "Provisionning failed" error message without any clue. You have to triple check everything.

Multipe Scope not working, Use Microsoft Graph API SDK

I have registered an app in the Azure AD portal and given Microsoft Graph API permissions to fetch user data (user.read.) and yammer feeds.
Note: the app is also registered with the yammer portal.
App auth is working fine if I have used a single scope but it fails in case of multiple scopes.
cases :
Working fine in single scope case
val SCOPES = arrayOf("https://graph.microsoft.com/.default")
Not Working in multiple scope case
val SCOPES = arrayOf("https://graph.microsoft.com/.default", "https://api.yammer.com/user_impersonation")
We are using Graph SDK in Android.
Thanks in Advance.
please suggest a way to achieve the solution.
You have set two scopes from different resources, which is not supported.
Because, finally you will get an Azure AD access token. However, the aud claim in the token can only represents one resource.
Conclusion:
You can add more than one scopes from one resource. For example: https://graph.microsoft.com/User.Read.All, https://graph.microsoft.com/Mail.ReadWrite and other scopes from Microsoft Graph.
If you want to get token for more than one resource, you need to get tokens for them separately.
I think we can add just user.read.all, mail.readwrite etc too without prefixing with entire graph URL, just that it needs to be comma separated.

Firebase authentification works but I get error when using the Google Text to Speech API

I've set up a small android and firebase app... Authentification works like a charm, and in the firebase console, I can see my user, logged in with the Google account.
Now I am trying to experiment a little with the Text to Speech api, and in doing so, I followed this tutorial:
https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/texttospeech/cloud-client
I managed to make the small java app work, by setting the GOOGLE_APPLICATION_CREDENTIALS Environment variable (I followed this tutorial for this step: https://cloud.google.com/docs/authentication/getting-started), but I am not sure what I need to do to make that code work in the Android app where the users are authentificated..
The Error that I get when trying to make a call to the TextToSpeech API is:
The Application Default Credentials are not available. They are
available if running in Google Compute Engine. Otherwise, the
environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined
pointing to a file defining the credentials. See
https://developers.google.com/accounts/docs/application-default-credentials
for more information.
The error mentioned comes from the line:
TextToSpeechClient textToSpeechClient = TextToSpeechClient.create();
This error appears because of the fact that on the android emulator I don't have access to the credentials that are set as environment variable in my OS..So I have to provide the credentials in another way.
In the case of other Google APIs, like Storage, I found out that this can be done like this:
// You can specify a credential file by providing a path to GoogleCredentials.
// Otherwise credentials are read from the GOOGLE_APPLICATION_CREDENTIALS environment variable.
GoogleCredentials credentials = GoogleCredentials.fromStream(new FileInputStream(jsonPath))
.createScoped(Lists.newArrayList("https://www.googleapis.com/auth/cloud-platform"));
Storage storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService();
I managed to create the GoogleCredentials object with the contents of the json file, however the TextToSpeech client doesn't seem to provide a functionality similar to this:
StorageOptions.newBuilder().setCredentials(credentials).build()
So my question is....is there a way to provide the Credentials object to the TextToSpeech client?
Thanks
Currently, there is not a way to provide credentials to the TTS Client from this page.
Due to Security / Auth reasons, I believe the best suggested approach is to use Firebase Functions.
Get the Text
Call Firebase Functions
Have Firebase Functions call the TTS API
Return the results.
This way, no keys are leaked inside the application and you can use Firebase Auth.
Let me know if that helps!
Update:
Option 2: iOS Tutorial (should be adaptable to Android)
Get the Text
Call Firebase Functions
Have Firebase Functions return an OAuth2 Token
Use the token directly with the API

Issue with Linkedin integration using socialauth in android

I had implmented linkedin integartion in my android app using socialauth a year ago. It was working fine till few days back. Now it gives following error:
"org.brickred.socialauth.exception.SocialAuthConfigurationException: Application keys are not correct. The server running the application should be same that was registered to get the keys."
Tried using following default keys also.
api.linkedin.com.consumer_key = bh82t52rdos6
api.linkedin.com.consumer_secret = zQ1LLrGbhDZ36fH8
Getting same error for keys of app generated previously, default app keys and for fresh created app.
Any idea why it is happening? Is there any change in linkedin APIs?
Libs included : socialauth-4.4.jar, socialauth-android-3.2.jar.
This is due to the change in the Linked in developer program.
Changes are mentioned here https://developer.linkedin.com/support/developer-program-transition.
You getting this error because the default scope setting in the r_fullprofile which is as part of the change no longer available.
So to apply this changes in the socialauth API you should pass the scope permission as <prop key="api.linkedin.com.custom_permissions">r_basicprofile,r_emailaddress</prop>
Linkedin have updated their Scope for API , they have updated their APIs link:https://developer.linkedin.com/support/developer-program-transition
The following selection of profile fields are available to all LinkedIn developers:
Basic Profile Fields
Location Fields
Position Fields
These fields are not
Full Profile Fields
Contact Info Fields
Company Fields
Publication Fields
Patent Fields
Language Fields
Skill Fields
Certification Fields
Course Fields
Education Fields
Volunteer Fields
Recommendation Fields.
Additionally
only these Profile API — /v1/people/~ Share API — /v1/people/~/shares Companies API — /v1/companies/{id} will work.
Check your scope.
LinkedIn locked many parts of its APIs on May 12, 2015 according to https://developer.linkedin.com/blog/posts/2015/developer-program-changes
Since you're using the socialauth library, you will have to wait for its developers to push a new version. :(
Downloading 4.9 library solves this issue
You can get the jar from Maven directly:
http://search.maven.org/remotecontent?filepath=org/brickred/socialauth/4.9/socialauth-4.9.jar

Deprecation of v1.0 of the API - What do I change to my existing code?

I am new to android development and learning. I'm creating an app which stores favorite twitter searches as tags which are clicked on and opened with. In my strings.xml I defined one of the tags as: <string name="searchURL">http://search.twitter.com/search?q=</string>
When I use the http://search.twitter.com/search?q= URL, I'am introduced to:
The Twitter REST API v1 is no longer active. Please migrate to API v1.1.
https://dev.twitter.com/docs/api/1.1/overview
I was wondering, what changes I should make to migrate to new version. Is it a simple change in the searchURL ?
from the link you sent:
At this time, all authentication requires user context, but in the
coming weeks we'll be pushing out support for a form of authentication
not requiring a user context.
I think that perfectly answer your question, isn't it?

Categories

Resources