Change password through graph api disallows german umlauts - azure-active-directory

I tried to change the users password through graph api to word containing german umlauts (e.g. ä, ö, ü, etc). But these passwords are rejected with error message :
"Invalid format: Invalid characters in password"
Through graph explorer I call
PATCH https://graph.microsoft.com/v1.0/me/
{
"passwordProfile": {
"forceChangePasswordNextSignIn": false,
"password": "Valid2018"
}
}
And it returns a Success - Status Code 200. But if I change the password to:
PATCH https://graph.microsoft.com/v1.0/me/
{
"passwordProfile": {
"forceChangePasswordNextSignIn": false,
"password": "Gültig2018"
}
}
I will get:
{
"error": {
"code": "Request_BadRequest",
"message": "Invalid format: Invalid characters in password",
"innerError": {
"request-id": "...",
"date": "..."
},
"details": [
{
"target": "password",
"code": "GenericError"
}
]
}
}
So why are german umlauts forbidden in Graph API??

Unfortunately,as juunas said that AAD doesn't allow non-Latin characters. For now, AAD Password policies that only allows following Characters:
A – Z
a - z
0 – 9
# # $ % ^ & * - _ ! + = [ ] { } | \ : ‘ , . ? / ` ~ “ ( ) ;
See more details about AAD Password policy in this document.

Related

How to get PubSub message data in an API?

I want to get this kind of message json data from Pub/Sub
{
"message": {
"data": {
"from": "no-reply#example.com",
"to": "user#example.com",
"subject": "test",
"body": "test"
}
}
}
And parse its data to use for other service.
private parseMessage(message: Message) {
try {
const decoded = Buffer.from(message.data.toString(), 'base64').toString().trim();
return JSON.parse(decoded);
} catch (err) {
throw new BadRequestException(
'Parse Error: ' + message,
);
}
}
But when run the API got this error:
SyntaxError: Unexpected token � in JSON at position 0
at JSON.parse (<anonymous>)
at EventController.parseMessage (../myapp/src/api/posts/posts.controller.ts:44:18)
response: {
statusCode: 400,
message: 'Parse Error: [object Object]',
error: 'Bad Request'
},
status: 400
It seems this post isn't right:
curl -X 'POST' \
'http://localhost:3000/posts' \
-H 'Content-Type: application/json' \
-d '{
"message": {
"data": {
"from": "no-reply#example.com",
"to": "user#example.com",
"subject": "test",
"body": "test"
}
}
}'
Then how to make fake Pub/Sub message data?
I think you need to encode your data into Base64.
Base64 encoding schemes need to encode binary data that needs to be stored and transferred over media that are designed to deal with ASCII. This is to ensure that the data remain intact without modification during transport.
You can also refer to this GCP public documentation.
Eg. From the Doc:
# 'world' base64-encoded is 'd29ybGQ='
curl localhost:8080 \
-X POST \
-H "Content-Type: application/json" \
-d '{
"context": {
"eventId":"1144231683168617",
"timestamp":"2020-05-06T07:33:34.556Z",
"eventType":"google.pubsub.topic.publish",
"resource":{
"service":"pubsub.googleapis.com",
"name":"projects/sample-project/topics/gcf-test",
"type":"type.googleapis.com/google.pubsub.v1.PubsubMessage"
}
},
"data": {
"#type": "type.googleapis.com/google.pubsub.v1.PubsubMessage",
"attributes": {
"attr1":"attr1-value"
},
"data": "d29ybGQ="
}
}'

Google Auth apis returns OPERATION_NOT_ALLOWED 400

I am using this API
https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[API_KEY]
I have pass correct token and param same as in documentation but still, it returns 400 OPERATION_NOT_ALLOWED
https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[API_KEY]
Param:-
{
"email": "test#test.com",
"password": "123123",
"returnSecureToken": true
}
Response
{
"error": {
"code": 400,
"message": "OPERATION_NOT_ALLOWED",
"errors": [
{
"message": "OPERATION_NOT_ALLOWED",
"domain": "global",
"reason": "invalid"
}
]
}
}
Go to firebase console -> authentication -> sign-in method
and then enable email/password providers

500 Error when trying to create schema extensions

I am trying to create schema extensions. I do have
"scp": "Directory.AccessAsUser.All" in token. Don't know for what reason it is failing.
https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/schemaextension_post_schemaextensions
POST https://graph.microsoft.com/beta/schemaExtensions
Content-type: application/json
{
"id":"courses",
"description": "Graph Learn training courses extensions",
"targetTypes": [
"Group"
],
"properties": [
{
"name": "courseId",
"type": "Integer"
},
{
"name": "courseName",
"type": "String"
},
{
"name": "courseType",
"type": "String"
}
]
}
error :
{
"error": {
"code": "Service_InternalServerError",
"message": "Encountered an internal server error.",
"innerError": {
"request-id": "1909aef3-b66d-48de-8204-0a41df0a27a8",
"date": "2017-07-17T13:07:20"
}
}
}
Unfortunately it looks like Microsoft Graph schema extensions is not supported in B2C tenant (please confirm if you are NOT using a B2C tenant - in which case this might be a different problem).
In the meantime (until we fix this issue), you'll need to use Azure AD Graph to register and use directory extensions.
Hope this helps,

Gmail API, cannot remove "SENT" label from email

I cannot remove the "SENT" label from any email.
I used PHP classes but it doesn't matter because it occurs even in test page of users_messages.modify.
This is my PHP code:
$mods = new Google_Service_Gmail_ModifyMessageRequest();
$mods->setAddLabelIds(['UNREAD']);
$mods->setRemoveLabelIds('SENT');
$message = $gmailService->users_messages->modify($userId, $messageId, $mods);
I think it could be a general Gmail API error.
I can remove all the others labels but not "SENT". Try it with the follow "Request body":
{
"removeLabelIds": ["SENT"],
"addLabelIds": ["UNREAD"]
}
I got this ERROR 400 reply from the server:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalidArgument",
"message": "Invalid label: SENT"
}
],
"code": 400,
"message": "Invalid label: SENT"
}
}
According to this google forum, there is no way of removing the SENT label in Gmail API.

dev_appserver.py locally rejects PATCH requests but accepts it on deployed

I've got an app based on djangoappengine, Backbone.js and Django REST Framework that uses PATCH requests to update models via {patch: true} on a model.save call.
I've found that when testing locally the dev_appserver returns:
ERROR 2014-02-19 04:37:04,531 dev_appserver.py:3081] code 501, message Unsupported method ('PATCH')
INFO 2014-02-19 04:37:04,532 dev_appserver.py:3090] "PATCH /api/posts/5707702298738688 HTTP/1.1" 501 -
Yet when I deploy it and access it through appspot the server happily accepts the request. Which forces me to deploy every time I make a change and want to test it.
I'm running the latests version (1.89) of the Python SDK, and found and old fixed issue that seems to tackle it but it seems other people have had it.
I tried this patch but it didn't make a difference. I don't understand why the development server would reject them and not the production server, is there something I need to change?
Thanks.
To update a resource, you can use POST with the x-http-method-override to patch. This is a valid RESTful operation and using POST will be more compatible with firewall and older user agents. The data in the request should indicate what is to be updated.
var url = '/api/posts/5707702298738688'
var patch_ops = [
{ "op": "replace", "path": "/properties/", "author": text}
{ "op": "add", "path": "/replies/", {"author": text, "comment":"blah"}}
/*
{ "op": "remove", "path": "/a/b/c" },
{ "op": "add", "path": "/a/b/c", "value": [ "foo", "bar" ] },
{ "op": "replace", "path": "/a/b/c", "value": 42 },
{ "op": "move", "from": "/a/b/c", "path": "/a/b/d" },
{ "op": "copy", "from": "/a/b/d", "path": "/a/b/e" }
*/
];
var xhr = jQuery.ajax({
type: "POST",
beforeSend: function (request)
{
request.setRequestHeader("X-HTTP-Method-Override", "PATCH");
},
url: url,
data: my_json_string,
dataType:"json",
success: function(data) {
return data;
},
error: function(xhr, textStatus, error){
return error;
}
});
Server handler:
def post(self, object_name):
if self.request.headers['x-http-method-override'] == 'PATCH':
# update according to patch operations
patch_ops_str= self.request.body.decode('utf-8')
try:
patch_ops = json.loads(new_area_geojson_str)
except:
self.response.set_status(400)
return self.response.out.write('{"status": "error", "reason": "JSON Parse error" }')
else:
self.response.set_status(405)
return self.response.out.write('{"status": "error", "reason": "post not accepted without x-http-method-override to PATCH" }')
Adapted from Please do not patch like an idiot

Resources