MobileFirst Adapters - Why am I getting a "401 Unauthorized" error when making request on Swagger Docs page in the MobileFirst Operations Console - ibm-mobilefirst

I am using MobileFirst CLI 8.0.0-2016070716, Java 1.8.0_91 (on Mac OS X 10.11.6 if it matters). I have been working through this tutorial on creating Java adapters using MobileFirst CLI.
After following the steps on creating, building, and deploying the adapter, I open the operations console and select the adapter I just deployed --> Resources --> "View Swagger Docs". When I press "Try it out" on any of the operations, I receive a "401 - Unauthorized" response code.
Any idea what problem might be?

"To add a Test Token to the request, so that the security framework skips any security challenges protecting your resource, click the on/off switch button on the right corner of an endpoint's operation.
You will be asked to select which scopes you want to grant to the Swagger UI (for testing purposes, you can select all). If you are using the Swagger UI for the first time, you might be required to log in with a Confidential Client ID and Secret. For this, you will need to create a new confidential client with * as its Allowed Scope."
Documentation regarding this is located here in our getting started tutorials.
https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/adapters/testing-and-debugging-adapters/#using-swagger

Related

"Invalid Client" with Auth0 and Sign In With Apple

I've implemented Sign in With Apple with Auth0 on iOS with react-native-auth0 but I am getting the following error when I attempt to sign in:
"Invalid Client"
I can't seem to figure out what might be misconfigured etc. Has anyone else run into this?
Using react-native-auth0#2.5.0
Ensure that the correct configuration elements are in place, both in the Auth0 Management Dashboard and in the Apple Developer Settings Console. Common configuration problems include:
Using the wrong identifier: Remember that Apple App IDs (also known
as App Bundle Identifiers) need to be configured in Auth0's advanced
application settings. Service IDs, which are used to configure web
apps, need to be configured in connection settings. Switching these
identifiers will result in failures.
More info here: https://auth0.com/docs/connections/apple-siwa/troubleshooting

How to test MobileFirst Adapter API outside of application

I am going through the tutorials of IBM MobileFirst. I have created an android application in MobileFirst and uploaded the Java HelloWorld adapter.
I can successfully trigger the API (such as the greet function) through my android app and I get back the desired result. But I would like to test the API also in the Browser, or through curl or through postman... But whenever I use the Browser or curl or Postman with:
http://localhost:XXXPORTXXX/mfp/api/adapters/SampleAdapter/resource/greet?name=myname
I dont get any string back... the browser stays empty and curl does not write anything...
If you're using MobileFirst v8, the adapter APIs are exposed as a Swagger doc. The swagger doc also gives you the curl command to run.
However, this works only on unprotected adapter methods.
If you wish you use this with protected methods, then you'll need to make use of a confidential client. See https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/authentication-and-security/confidential-clients/

PushSharp - GCM Authorization Failed

Using v4.0.10 of Pushsharp (nuget package), I am getting error GCM Authorization Failed when sending push notifications to Android devices.
Seems the bug raised in issue 574 (https://github.com/Redth/PushSharp/issues/574 ) has been compiled into the nuget package, yet I'm still getting this error.
Could this be related to the introduction of Firebase Cloud Messaging?
Does anyone still have success using GCM?
As of right now, GCM is still usable. However, it is highly encouraged for new users to use FCM instead. Either way, for both GCM and FCM, you must use a Server Key generated from the Firebase Console. There is a visible note in the GCM docs saying:
Starting from Sept. 2016 new server key can only be created in the Firebase Console using the Cloud Messaging tab of the Settings panel. Existing projects that need to create a new server key can be imported in the Firebase console without affecting their existing configuration.
The Authorization error has been encountered by number of users, some also had an old project. See my answer here for more details.
The sender id used in the app code needs to match the sender id Firebase Cloud Message Console and its corresponding "Firebase Cloud Messaging token".
Thank you #AL for your help.

Azure App Service Oauth failure after Mobile Service migration

Up to this point, I had a functioning Azure Mobile Service with service-directed OAuth working nicely for Google. I tried to rehost the mobile service as an app service since mobile services are deprecated. I also have an HTML/JS web app that accesses my service through the MobileServiceClient JS client. This is where the fun starts.
After changing the redirect address to the appropriate app service address in the Google API manager, I get a message saying I'm successfully logged in in a new popup window: .
Clicking on "Return to Website" takes me to the address of my app service, not the app that initiated the OAuth request, and if I close this window, the MobileServiceClient throws a "cancelled" exception and I don't get my credentials.
What am I missing or what changed that I need to account for?
Thanks!
It turns out that this particular behavior happens when using an older version of the MobileServiceClient JS library. Replacing the 1.2.7 version with the 2.0.0beta version fixed this. To get the whole OAuth flow working, I also needed to add the appropriate addresses to the allowedExternalRedirectUrls node of the config/authsettings node through the Azure Resource Explorer. If there is a nicer way to do it than through the resource explorer, I don't know what it is.

How to configure Android Push Notifications (GCM) in Appcelerator Titanium Dashboard?

I've tried to following the instructions
Configuring push services for Android devices
However, the steps mention 'Click Push Notifications on the left-side navigation' but they don't exist...
Once you've created a Google API project with GCM enabled, you need to update your application's settings page in Dashboard with the API key and sender ID you generated.
To configure Arrow for push notifications using Dashboard:
Open Dashboard and select your application from the Apps drop-down menu.
Click Push Notifications on the left-side navigation <-- MISSING.
Select the Android Push tab.
Enter the server key in the GCM API Key field and the GCM sender ID in the GCM Sender ID field.
Here's a screenshot to show what's listed...
If I look under Arrow (where I suspect it might be expecting to be listed) that's empty (I'm not using Arrow - I thought it was an alternative UI using declarative XML)...
I've checked the subscription that I'm on (Indie) and it shows that I should have the ability to send up to 1 million push notifications for free..
Does anyone know how I can associate the Appcelerator Titanium project to the GCM server key??
Also, when I looked in Googles developer console, my application (which is live on their app store) wasn't listed, so I've created a new application called 'Gcm'. The Appcelerator Titanium seemed to confirm that I needed to 'create' the application, I was just too worried to call it the same name as the live application. How does the 'Google Developer Console' Application relate to the 'Google Play' application?! - if at all?
UPDATE
I've just discovered in TiApp.xml that I can enable some 'Cloud' settings and this has unlocked the 'Push' menu - so I think all is good now, could someone confirm that this is the right thing to do and answer my related question about Google play applications v google developer console applications?
Update 2
I started to get this error
[ERROR] : GooglePlayServicesUtil: The Google Play services resources
were not found. Check your project configuration to ensure that the
resources are included.
[INFO] : CloudPush.retrieveDeviceToken error: INVALID_SENDER
I'm simply calling this to try and register for Android push notifications ...
CloudPush.retrieveDeviceToken({
success : function(e) {
console.info("CloudPush.retrieveDeviceToken success");
},
error : function(e) {
console.info("CloudPush.retrieveDeviceToken error:"+e.error);
}
});
I have tried with and without the ti.cloud module (I think it got added when I clicked the 'Enable Services' button which meant that I could see the 'Push Notifications' tab, but it seems to still be listed whether the ti.cloud module is elected or not)..
Before..
Q - How to stop the Google Play error and retrieve the device token (oddly I was getting the token before enable services.
Q - Is ti.cloud used to receive the push notification, or is ti.cloudpush sufficient for this?
Thanks for the detailed question :) Let me go into some of the things you mention and clarify what I can.
If I look under Arrow (where I suspect it might be expecting to be listed) that's empty
As you later found out you have to enable platform services for your app which will create an ArrowDB app with the same name as your app. This app will have the Push Notifications in the sidebar to configure. I've updated the guide's wordings to make clear we mean the ArrowDB app, not the Titanium app.
(I'm not using Arrow - I thought it was an alternative UI using declarative XML)...
Don't confuse Arrow with Alloy - which is the MVC framework for Titanium which indeed uses XML.
How does the 'Google Developer Console' Application relate to the 'Google Play' application?! - if at all?
It doesn't. You can even have multiple apps share the same GCM sender.
[ERROR] : GooglePlayServicesUtil: The Google Play services resources were not found.
What did you use to test? A Genymotion emulator without Google Apps installed perhaps? You'll need that.
Is ti.cloud used to receive the push notification, or is ti.cloudpush sufficient for this?
ti.cloud is the module to communicate with ArrowDB, subscribe to channels etcetera. On Android you need ti.cloudpush (or as #Shawn mentioned another module) to retrieve the device token where on iOS you can use a Ti. API for that. Follow this guide for all steps.
You can ignore the Google Play Service error, but it seems your GCM Sender ID and/or API Key is wrong. Read through the tutorial and make sure you put down the right ones.
If you are using Appcelerator Cloud Service to send push notifications, you need ti.cloud to register the devices.
To get the device token and to receive push notifications, you use ti.cloudpush. There are other modules that you can use instead of ti.cloudpush.