Google App Engine - Deployment not working - google-app-engine

I have a Google App Engine project (an API) working against a Google Cloud SQL instance. I have a exact copy of both, the API and the SQL instance, running local.
When I execute the project on development (local), I can explore the API just fine. Yet, when I go on deployment, all the calls return empty.
This is the API code (Java):
#ApiMethod(
name = "test.users.list",
path = "test/users/list",
httpMethod = "get"
)
public UserList testUserList ()
{
UserList users = UserList.getAll();
return users;
}
This is what it returns local:
{
"users": [
{
"id": "3",
"firstName": "Test",
"lastName": "User",
"email": "test#test.com",
"password": "12fc892642c48a8227410f5b6722e1edeeefedfb",
"logins": 0,
"lastLogin": 0,
"roles": [
{
"id": "1",
"name": "user",
"loaded": true
}
],
"fullName": "Test User",
"admin": false,
"lastLoginDat": "1969-12-31T21:00:00.000-03:00",
"loaded": true
},
{
"id": "6",
"firstName": "Test",
"lastName": "User 2",
"email": "test2#test.com",
"password": "c5bc2a33ddffcfb3d61779ab44d7d933e1336b02",
"logins": 0,
"lastLogin": 0,
"fullName": "Test User 2",
"admin": false,
"lastLoginDat": "1969-12-31T21:00:00.000-03:00",
"loaded": true
}
]
}
This is what it returns on the server explorer:
{
"kind": "myapp#usersItem",
"etag": "\"l4AE0sdQvyB-SkumpjWQFJVUZzo/MSGC-asdfasdf\""
}
Some insight:
I have access (through MySQL Workbench) to the local SQL instance and the Google Cloud SQL external instance.
Both, local and external SQL instances, are equal to each other.
I've also guaranteed access to the project I'm using to hit the DB (trough the Google Cloud panel).
I don't really know what to do or check. I've searched for something similar but couldn't find anything related.
Any thought is appreciated.

As Jan pointed out, GAE local and production are two separate stories. But I'm gonna give you something even better than this particular solution, which is the tools to resolve this and further problems:
1. Go to Console > Compute > App Engine > Versions, and make sure the backend version you uploaded is the right one (take a look at the time it was uploaded) and is selected or default.
2. Create an API test method that does a rather basic operation against the DB, but without calling other methods nor using try/catch blocks. You're trying to raise a exception here, if any. All the code you need to hit the DB and return the data should be inside that method.
3. Go to the explorer panel, and execute your test method. If it works, then your problem is not in the connection, but in the logic. Use the same approach of (2) to test the logic.
4. If the method doesn't work, go to: Console > Monitoring > Logs. There you'll find the exception trace.

Related

Alexa model evaluation works great but intent is never called in simulator or alexa device

I'm struggling to build my Alexa Interaction model. My application is used for requesting live data from a smart home device. All i do is basically calling my Server API with a Username & Password and i get a value in return. My interaction model works perfectly for requesting the parameters, for example i can say "Temperature" and it works perfectly fine across all testing devices. For that intent i got a custom RequestType.
However for setting up Username & Password i need to use an built-it slot type: AMAZON.NUMBER. As i only need numbers for my credentials this should work perfectly fine in theory.
I got a interaction model setup which works perfectly fine when i press "Evaluate Model" in Alexa developer console. However once i go to Test on the simulator or to my real Alexa device it's absolutely impossible to call the intent. It always calls one of more other intents? (I see this in the request JSON).
Here's how the intent looks:
{
"name": "SetupUsername",
"slots": [
{
"name": "username",
"type": "AMAZON.NUMBER"
}
],
"samples": [
"my user id is {username}",
"username to {username}",
"set my username to {username}",
"set username to {username}",
"user {username}",
"my username is {username}",
"username equals {username}"
]
}
Whatever i say or type in the Simulator, i cannot call this intent. I have no overlaps from other intents. Does anyone see an issue here?
Thank you in advance
EDIT: I just realized that if you want to do account linking on Alexa you need to implement OAuth2 - maybe my intents are never called because they want to bypass me implementing my own authentication?
UPDATE:
This is the intent that is usually called instead - it's my init intent. So for example is i say "my username is 12345" the following intent is gonna be called:
UPDATE 2:
Here is my full interaction model.
(HelpIntent and SetPassword are only for testing purposes, they don't make sense right now)
It's impossible calling SetupUsername with any of the samples in my model.
You need to build the interaction model. Saving is not enough
When you develop your Interaction Model, you have to save it AND build it. Otherwise only the evaluation model will work (documentation about it).
Then when you test in the test console, you should see in the JSON Input, at the bottom, which intent was called:
"request": {
"type": "IntentRequest",
"requestId": "xxxx",
"locale": "en-US",
"timestamp": "2021-10-20T14:38:59Z",
"intent": {
"name": "HelloWorldIntent", <----------- HERE
"confirmationStatus": "NONE"
}
}

Using Azure AD Graph API to create a User in Azure AD B2C

My application was designed to add a user to my Azure AD B2C using Azure AD Graph API. I also handled the case where I'd be calling the add user graph API with an email ID that already exists in AD. I was looking for the error message in the response body to handle this. Has there been any change w.r.t the response message?
POST
https://graph.windows.net/{tenant}/users?api-version=1.6
Request Body :
{
"accountEnabled": true,
"signInNames": [
{
"type": "EmailAddress",
"value": "TestGraphApiCreatedUser#TestGraphApiCreatedUser.com"
}],
"displayName": "TestGraphApiCreatedUser",
"mailNickname": "TestGraphApiCreatedUser",
"passwordProfile" : {
"forceChangePasswordNextLogin": false,
"password": "vhkjds#fceu456VCHU"
},
"creationType": "LocalAccount",
"passwordPolicies": "DisablePasswordExpiration"
}
If a user already exists with the given email address, the error I was getting earlier was
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "Another object with the same value for property signInName already exists."
}
}
}
Now, for the same flow, I'm getting below error :
{
"odata.error": {
"code": "Request_BadRequest",
"message": {
"lang": "en",
"value": "Another object with the same value for property userPrincipalName already exists."
}
}
}
Is there any difference between the two error messages. Since there isn't any error code, I had hard coded the whole error message. Now that there is a slight change in the message, I've to update my code. How can I handle this in a better way?
I didn't check to confirm if they changed the error message, but it wouldn't surprise me at all if they did. The userPrincipalName may be coming from the underlying AAD, maybe MS changed the B2C implementation and now it exposes an error message from there?
In your particular case, a better option may be to check if the email address exists in B2C just before calling the API to create the new user. It's an extra API call, but it shouldn't matter much unless you're creating many users at a time, e.g. in a batch. You'll still have to handle the user creation call failure, but if it happens you could just return a generic error message.

Unable to create a local account via graph api in Azure B2C

I am trying to create a "LocalAccount" in a B2C domain via the Azure AD Graph API.
To do this I registered an app (via Azure Active Directory -> App registrations (legacy)) and add all permissions for "Windows Azure Active Directory".
The request to create the user is
add_user_json = {
"accountEnabled": True,
"creationType": "LocalAccount",
"signInNames": [{
"type": "emailAddress",
"value": "test#email.com"
},
{
"type": "emailAddress",
"value": "test2#email.com"
}],
"displayName": user_id,
"mailNickname": user_id,
"passwordProfile": {
"password": "aPassword",
"forceChangePasswordNextLogin": "true"
},
"passwordPolicies": "DisablePasswordExpiration"
}
and the endpoint "https://graph.windows.net/{tenant}.onmicrosoft.com/users?api-version=1.6" (I tried "https://graph.windows.net/myorganization/users?api-version=1.6", too).
The error I get is "One or more properties contains invalid values."
Furthermore, if I create a new user via the sign up flow it is possible to create a local account.
Does anybody have an idea what I did wrong?
The "One or more properties contains invalid values." error is occurring because a user object can't have more than one signInName entry of the same type.
There's a really good utility here with the code to help you.
Look at the create example there
One obvious one is:
"forceChangePasswordNextLogin": "true"
This needs to be "false".

Adding a Custom Attribute (Extension) in B2C using Azure AD Graph API doesn't show up in Azure Portal User Attributes blade

The same question was asked here and remains unanswered. I can add a custom attribute as follows:
{
"name": "new_secure_claim",
"dataType": "Boolean",
"targetObjects": ["User"]
}
I post this data to the Azure AD Graph API end point with needed headers:
https://graph.windows.net/{tenant}.onmicrosoft.com/applications/{objectId of b2c-extensions-app}/extensionProperties?api-version=1.6. I get a response with the extension just created. I can even see the extension when I query the graph to get all extensions for the b2c-extensions-app (notice the top one below):
{
"odata.metadata": "https://graph.windows.net/melangeauth.onmicrosoft.com/$metadata#directoryObjects/Microsoft.DirectoryServices.ExtensionProperty",
"value": [{
"odata.type": "Microsoft.DirectoryServices.ExtensionProperty",
"objectType": "ExtensionProperty",
"objectId": "b7a36f93-8d7a-463f-8d3e-88f449243ea6",
"deletionTimestamp": null,
"appDisplayName": "",
"name": "extension_8588c037999f4d058cc08e2e5f99de30_new_secure_claim",
"dataType": "Boolean",
"isSyncedFromOnPremises": false,
"targetObjects": ["User"]
}, {
"odata.type": "Microsoft.DirectoryServices.ExtensionProperty",
"objectType": "ExtensionProperty",
"objectId": "b6c6d55f-21a8-4403-a68f-f858966077bf",
"deletionTimestamp": null,
"appDisplayName": "",
"name": "extension_8588c037999f4d058cc08e2e5f99de30_manager_admin_authorization",
"dataType": "Boolean",
"isSyncedFromOnPremises": false,
"targetObjects": ["User"]
}, {
"odata.type": "Microsoft.DirectoryServices.ExtensionProperty",
"objectType": "ExtensionProperty",
"objectId": "2642596f-5706-47fb-abdb-6d0d012a3006",
"deletionTimestamp": null,
"appDisplayName": "",
"name": "extension_8588c037999f4d058cc08e2e5f99de30_manager_admin",
"dataType": "Boolean",
"isSyncedFromOnPremises": false,
"targetObjects": ["User"]
}, {
"odata.type": "Microsoft.DirectoryServices.ExtensionProperty",
"objectType": "ExtensionProperty",
"objectId": "ee2c66e3-ced4-4bc8-90d5-e2b18690a56b",
"deletionTimestamp": null,
"appDisplayName": "",
"name": "extension_8588c037999f4d058cc08e2e5f99de30_manager_ads_admin",
"dataType": "Boolean",
"isSyncedFromOnPremises": false,
"targetObjects": ["User"]
}
]
}
But, when I go to the "Azure AD B2C/User attributes" blade in my B2C directory in the Azure portal (https://portal.azure.com/#blade/Microsoft_AAD_B2CAdmin/TenantManagementMenuBlade/manageUserAttributes), I cannot see that extension attribute. I also cannot see it when I go to add claims to return for a policy.
What do I need to do differently in the adding of a custom extension to the b2c-extensions-app application in order for me to see if in the Azure portal User attributes blade?
Well, hmm.
It gets complicated when people things in an undocumented way. For sake of simplicity I would encourage you to stay with defining your extensions with the portal. If you just want to do that (and seems you want). Because there is much more than just registering an extension with the Graph.
To understand why is that, you have to more deeply understand how B2C ticks from the inside. You get overview when you dive into custom policies. However custom policies are, as it stays in the docs, for identity pros who know what are they doing. Straight to the point, the claims schema is defined in so called base policy. It is not just defined in the Graph, but also backed in the base policy. There is XML schema which dictates what a B2C must do and how it should do it. And all the claims (and custom attributes) are also defined in that schema. So when you change something regarding this schema in the portal (adding new attribute), it is registered with the Graph API, but it is also updated in the claims definition schema, which is kept separately.
That's why when you manually register an extension with the Graph it just does not show up in the portal.
I do not expect that you jump and begin learning Custom policies, because for your case you just do not need them. But I hope that having to define your custom attributes in the portal is not a big of an issue for you.

Delta Query for user resource: How to get only changed attributes

I am using Microsoft Graph API delta query to track changes in my Azure AD.
I want to obtain only changed properties. So I have set 'ocp-aad-dq-include-only-changed-properties' header value to 'true' to get only changed properties. But even after using this header I am receiving all user properties.
Is there any other option to get only changed properties? or Do I need to use any other header?
Given below the detail description of the operations that I am trying.
Example:
Initial Delta request
GET https://graph.microsoft.com/v1.0/users/delta?$select=displayName,givenName,surname
Headers:
ocp-aad-dq-include-only-changed-properties : true
Response:
In the initial response, I am getting all users.
DeltaLink request after updating 'displayName' attribute
GET https://graph.microsoft.com/v1.0/users/delta?$deltatoken=KhFiGlAZqewNAThmCVnNxqPu5gOBegrm1CaV
Headers:
ocp-aad-dq-include-only-changed-properties : true
Here I have added 'ocp-aad-dq-include-only-changed-properties' header still I am getting all attributes of the User
Response:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
"#odata.deltaLink": "https://graph.microsoft.com/v1.0/users/delta?$deltatoken=o8xFasdpZ7QDP14TyDfj9AeibJxMlXAtgB0Nb",
"value": [
{
"businessPhones": [],
"displayName": "jhon4",
"givenName": null,
"jobTitle": null,
"mail": null,
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": null,
"userPrincipalName": "jhon.smith#testdomain.onmicrosoft.com",
"id": "942h93c9-af17-6sad2d98cc8"
}
]
}
Update Request
PATCH https://graph.microsoft.com/v1.0/users/jhon.smith#testdomain.onmicrosoft.com
Payload:
{
"displayName": "jhon4",
}
The ocp-aad-dq-include-only-changed-properties header is a feature of the Azure AD Graph API and isn't supported in Microsoft Graph.
While they're extremely similar, these two APIs have several distinct features differences (such as this one). You can read more about the differences (and the overall plan) at Microsoft Graph or the Azure AD Graph.
to get only the changed properties, use this header:
prefer:return=minimal

Resources