Archive
Obtaining an Access Token for Outlook Web Access (#OWA) Using a Consumer Account

If you need programmatic access to Outlook Web Access (OWA) using a Microsoft consumer account (e.g., an Outlook.com, Hotmail, or Live.com email), you can obtain an access token using the Microsoft Authentication Library (MSAL). The following C# code demonstrates how to authenticate a consumer account and retrieve an access token.
Prerequisites
To run this code successfully, ensure you have:
- .NET installed
- The
Microsoft.Identity.ClientNuGet package - A registered application in the Microsoft Entra ID (formerly Azure AD) portal with the necessary API permissions
Code Breakdown
The following code authenticates a user using the device code flow, which is useful for scenarios where interactive login via a browser is required but the application does not have direct access to a web interface.
1. Define Authentication Metadata
var authMetadata = new
{
ClientId = "9199bf20-a13f-4107-85dc-02114787ef48", // Application (client) ID
Tenant = "consumers", // Target consumer accounts (not work/school accounts)
Scope = "service::outlook.office.com::MBI_SSL openid profile offline_access"
};
- ClientId: Identifies the application in Microsoft Entra ID.
- Tenant: Set to
consumersto restrict authentication to personal Microsoft accounts. - Scope: Defines the permissions the application is requesting. In this case:
service::outlook.office.com::MBI_SSLis required to access Outlook services.openid,profile, andoffline_accessallow authentication and token refresh.
2. Configure the Authentication Application
var app = PublicClientApplicationBuilder
.Create(authMetadata.ClientId)
.WithAuthority($"https://login.microsoftonline.com/{authMetadata.Tenant}")
.Build();
- PublicClientApplicationBuilder is used to create a public client application that interacts with Microsoft identity services.
.WithAuthority()specifies that authentication should occur against Microsoft’s login endpoint for consumer accounts.
3. Initiate the Device Code Flow
var scopes = new string[] { authMetadata.Scope };
var result = await app.AcquireTokenWithDeviceCode(scopes, deviceCodeResult =>
{
Console.WriteLine(deviceCodeResult.Message); // Display login instructions
return Task.CompletedTask;
}).ExecuteAsync();
- AcquireTokenWithDeviceCode() initiates authentication using a device code.
- The
deviceCodeResult.Messageprovides instructions to the user on how to authenticate (typically directing them tohttps://microsoft.com/devicelogin). - Once the user completes authentication, the application receives an access token.
4. Retrieve and Display the Access Token
Console.WriteLine($"Access Token: {result.AccessToken}");
- The retrieved token can now be used to make API calls to Outlook Web Access services.
5. Handle Errors
catch (MsalException ex)
{
Console.WriteLine($"Authentication failed: {ex.Message}");
}
- MsalException handles authentication errors, such as incorrect permissions or expired tokens.
Running the Code
- Compile and run the program.
- Follow the login instructions displayed in the console.
- After signing in, the access token will be printed.
- Use the token in HTTP requests to Outlook Web Access APIs.
Conclusion
This code provides a straightforward way to obtain an access token for Outlook Web Access using a consumer account. The device code flow is particularly useful for command-line applications or scenarios where interactive authentication via a browser is required.
#UFG #API for Poland – Vehicle Insurance Details

How to Use the API for Vehicle Insurance Details in Poland
If you’re working in the insurance industry, vehicle-related services, or simply need a way to verify a car’s insurance status in Poland, there’s a powerful API available to help you out. This API provides quick and reliable access to current insurance details of a vehicle, using just the license plate number.
Overview of the API Endpoint
The API is accessible at the following endpoint:
https://www.tablicarejestracyjnaapi.pl/api/bespokeapi.asmx?op=CheckInsuranceStatusPoland
This endpoint retrieves the insurance details for vehicles registered in Poland. It uses the license plate number as the key input to return the current insurance policy information in XML format.
Key Features
The API provides the following details about a vehicle:
- PolicyNumber: The unique policy number of the insurance.
- Vehicle: The make and model of the vehicle.
- Company: The insurance company providing the policy.
- Address: The company’s registered address.
- IsBlacklisted: A boolean field indicating whether the vehicle is blacklisted.
Below is an example of the XML response:
<InsurancePolicy xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://Regcheck.org.uk/">
<PolicyNumber>920040143596</PolicyNumber>
<Vehicle>RENAULT ARES 826 RZ</Vehicle>
<Company>TOWARZYSTWO UBEZPIECZEŃ I REASEKURACJI WARTA S.A.</Company>
<Address>rondo I. Daszyńskiego 1, 00-843 Warszawa</Address>
<IsBlacklisted>false</IsBlacklisted>
</InsurancePolicy>
How to Use the API
- Send a Request: To use the API, you need to send an HTTP request to the endpoint. Typically, you’ll pass the vehicle’s license plate number as a parameter in the request body or URL query string.
- Process the Response: The response will be in XML format. You can parse the XML to extract the details you need, such as the policy number, the name of the insurance provider, and the vehicle’s blacklisting status.
Example Use Case
Imagine you’re developing a mobile application for a car rental service in Poland. Verifying the insurance status of vehicles in your fleet is crucial for compliance and operational efficiency. By integrating this API, you can:
- Automate insurance checks for newly added vehicles.
- Notify users if a vehicle’s insurance policy has expired or if the vehicle is blacklisted.
- Display detailed insurance information in the app for transparency.
Integration Tips
- Error Handling: Ensure your application handles scenarios where the API returns errors (e.g., invalid license plate numbers or no records found).
- XML Parsing: Use robust XML parsers available in your development language to process the API response efficiently.
- Security: If the API requires authentication, make sure you secure your API keys and follow best practices for handling sensitive information.
Sample Code
Here’s a quick example of how you can call the API in C#:
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Xml;
class Program
{
static async Task Main(string[] args)
{
string licensePlate = "WE12345"; // Example license plate number
string apiUrl = "https://www.tablicarejestracyjnaapi.pl/api/bespokeapi.asmx?op=CheckInsuranceStatusPoland";
using HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(apiUrl + "?licensePlate=" + licensePlate);
if (response.IsSuccessStatusCode)
{
string responseContent = await response.Content.ReadAsStringAsync();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(responseContent);
string policyNumber = xmlDoc.SelectSingleNode("//PolicyNumber")?.InnerText;
string vehicle = xmlDoc.SelectSingleNode("//Vehicle")?.InnerText;
string company = xmlDoc.SelectSingleNode("//Company")?.InnerText;
string address = xmlDoc.SelectSingleNode("//Address")?.InnerText;
string isBlacklisted = xmlDoc.SelectSingleNode("//IsBlacklisted")?.InnerText;
Console.WriteLine($"Policy Number: {policyNumber}\nVehicle: {vehicle}\nCompany: {company}\nAddress: {address}\nBlacklisted: {isBlacklisted}");
}
else
{
Console.WriteLine("Failed to retrieve data from the API.");
}
}
}
Conclusion
The API for vehicle insurance details in Poland is a valuable tool for businesses and developers looking to integrate reliable insurance data into their applications. Whether you’re building tools for insurance verification, fleet management, or compliance monitoring, this API provides an efficient way to access up-to-date information with minimal effort.
Start integrating the API today and take your application’s functionality to the next level!
License plate lookup #API now available for #Albania

If you’re working with vehicle registration data in Albania, the /CheckAlbania endpoint from API.com.al is an invaluable resource. It provides a comprehensive set of details for any car registered in Albania, offering insights into the vehicle’s specifications, registration details, and even a representative image.
Here’s what you need to know about the /CheckAlbania endpoint and how it can enhance your applications.
What Information Does /CheckAlbania Provide?
The endpoint delivers a structured JSON response containing key vehicle details, making it easy to integrate with applications. Below is an overview of the information returned:
- Make: Identifies the car manufacturer (e.g., AUDI).
- Age: The year of registration.
- Engine Size & Power: The vehicle’s engine size (in cc) and power output.
- Colour: Describes the car’s exterior color (e.g., “KUQE” for red).
- Traffic Permit: A unique identifier for the vehicle’s traffic permit.
- Representative Image: A URL pointing to a representative image of the car.
Albania Support
Car registration plates in Albania use the /CheckAlbania endpoint and returns the following information:
- Make
- Age
- Engine Size & Power
- Colour
- Traffic Permit
- Representative image
Sample Registration Number:
AB404GM
Sample Json:
{
Description: “AUDI AUTOVETURE”,
RegistrationYear: “2009”,
CarMake: {
CurrentTextValue: “AUDI”,
},
CarModel: {
CurrentTextValue: “AUTOVETURE”,
},
MakeDescription: {
CurrentTextValue: “AUDI”,
},
ModelDescription: {
CurrentTextValue: “AUTOVETURE”,
},
NumberOfSeats: “5”,
Power: “2967”,
Colour: “KUQE”,
TrafficPermit: “0000000358602”,
Owner: “”,
EngineSize: “2490”,
Region: “”,
ImageUrl: “http://www.api.com.al/image.aspx/@QVVESSBBVVRPVkVUVVJF“,
}
How to Extract #EXIF Data from an Image in .NET 8 with #MetadataExtractor

GIT REPO : https://github.com/infiniteloopltd/ExifResearch
When working with images, EXIF (Exchangeable Image File Format) data can provide valuable information such as the camera model, date and time of capture, GPS coordinates, and much more. Whether you’re building an image processing application or simply want to extract metadata for analysis, knowing how to retrieve EXIF data in a .NET environment is essential.
In this post, we’ll walk through how to extract EXIF data from an image in .NET 8 using the cross-platform MetadataExtractor library.
Why Use MetadataExtractor?
.NET’s traditional System.Drawing.Common library has limitations when it comes to cross-platform compatibility, particularly for non-Windows environments. The MetadataExtractor library, however, is a powerful and platform-independent solution for extracting metadata from various image formats, including EXIF data.
With MetadataExtractor, you can read EXIF metadata from images in a clean, efficient way, making it an ideal choice for .NET Core and .NET 8 developers working on cross-platform applications.
Step 1: Install MetadataExtractor
To begin, you need to add the MetadataExtractor NuGet package to your project. You can install it using the following command:
bashCopy codedotnet add package MetadataExtractor
This package supports EXIF, IPTC, XMP, and many other metadata formats from various image file types.
Step 2: Writing the Code to Extract EXIF Data
Now that the package is installed, let’s write some code to extract EXIF data from an image stored as a byte array.
Here is the complete function:
using System;
using System.Collections.Generic;
using System.IO;
using MetadataExtractor;
using MetadataExtractor.Formats.Exif;
public class ExifReader
{
public static Dictionary<string, string> GetExifData(byte[] imageBytes)
{
var exifData = new Dictionary<string, string>();
try
{
using var ms = new MemoryStream(imageBytes);
var directories = ImageMetadataReader.ReadMetadata(ms);
foreach (var directory in directories)
{
foreach (var tag in directory.Tags)
{
// Add tag name and description to the dictionary
exifData[tag.Name] = tag.Description;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error reading EXIF data: {ex.Message}");
}
return exifData;
}
}
How It Works:
- Reading Image Metadata: The function uses
ImageMetadataReader.ReadMetadatato read all the metadata from the byte array containing the image. - Iterating Through Directories and Tags: EXIF data is organized in directories (for example, the main EXIF data, GPS, and thumbnail directories). We iterate through these directories and their associated tags.
- Handling Errors: We wrap the logic in a
try-catchblock to ensure any potential errors (e.g., unsupported formats) are handled gracefully.
Step 3: Usage Example
To use this function, you can pass an image byte array to it. Here’s an example:
using System;
using System.IO;
class Program
{
static void Main()
{
// Replace with your byte array containing an image
byte[] imageBytes = File.ReadAllBytes("example.jpg");
var exifData = ExifReader.GetExifData(imageBytes);
foreach (var kvp in exifData)
{
Console.WriteLine($"{kvp.Key}: {kvp.Value}");
}
}
}
This code reads an image from the file system as a byte array and then uses the ExifReader.GetExifData method to extract the EXIF data. Finally, it prints out the EXIF tags and their descriptions.
Example Output:
If the image contains EXIF metadata, the output might look something like this:
"Compression Type": "Baseline",
"Data Precision": "8 bits",
"Image Height": "384 pixels",
"Image Width": "512 pixels",
"Number of Components": "3",
"Component 1": "Y component: Quantization table 0, Sampling factors 2 horiz/2 vert",
"Component 2": "Cb component: Quantization table 1, Sampling factors 1 horiz/1 vert",
"Component 3": "Cr component: Quantization table 1, Sampling factors 1 horiz/1 vert",
"Make": "samsung",
"Model": "SM-G998B",
"Orientation": "Right side, top (Rotate 90 CW)",
"X Resolution": "72 dots per inch",
"Y Resolution": "72 dots per inch",
"Resolution Unit": "Inch",
"Software": "G998BXXU7EWCH",
"Date/Time": "2023:05:02 12:33:47",
"YCbCr Positioning": "Center of pixel array",
"Exposure Time": "1/33 sec",
"F-Number": "f/2.2",
"Exposure Program": "Program normal",
"ISO Speed Ratings": "640",
"Exif Version": "2.20",
"Date/Time Original": "2023:05:02 12:33:47",
"Date/Time Digitized": "2023:05:02 12:33:47",
"Time Zone": "+09:00",
"Time Zone Original": "+09:00",
"Shutter Speed Value": "1 sec",
"Aperture Value": "f/2.2",
"Exposure Bias Value": "0 EV",
"Max Aperture Value": "f/2.2",
"Metering Mode": "Center weighted average",
"Flash": "Flash did not fire",
"Focal Length": "2.2 mm",
"Sub-Sec Time": "404",
"Sub-Sec Time Original": "404",
"Sub-Sec Time Digitized": "404",
"Color Space": "sRGB",
"Exif Image Width": "4000 pixels",
"Exif Image Height": "3000 pixels",
"Exposure Mode": "Auto exposure",
"White Balance Mode": "Auto white balance",
"Digital Zoom Ratio": "1",
"Focal Length 35": "13 mm",
"Scene Capture Type": "Standard",
"Unique Image ID": "F12XSNF00NM",
"Compression": "JPEG (old-style)",
"Thumbnail Offset": "824 bytes",
"Thumbnail Length": "49594 bytes",
"Number of Tables": "4 Huffman tables",
"Detected File Type Name": "JPEG",
"Detected File Type Long Name": "Joint Photographic Experts Group",
"Detected MIME Type": "image/jpeg",
"Expected File Name Extension": "jpg"
This is just a small sample of the information EXIF can store. Depending on the camera and settings, you may find data on GPS location, white balance, focal length, and more.
Why Use EXIF Data?
EXIF data can be valuable in various scenarios:
- Image processing: Automatically adjust images based on camera settings (e.g., ISO or exposure time).
- Data analysis: Track when and where photos were taken, especially when handling large datasets of images.
- Digital forensics: Verify image authenticity by analyzing EXIF metadata for manipulation or alterations.
Conclusion
With the MetadataExtractor library, extracting EXIF data from an image is straightforward and cross-platform compatible. Whether you’re building a photo management app, an image processing tool, or just need to analyze metadata, this approach is an efficient solution for working with EXIF data in .NET 8.
By using this solution, you can extract a wide range of metadata from images, making your applications smarter and more capable. Give it a try and unlock the hidden data in your images!