Skip to content

Instantly share code, notes, and snippets.

View isvargasmsft's full-sized avatar

Isaac Vargas isvargasmsft

  • Microsoft
  • San Jose, Costa Rica
View GitHub Profile
@isvargasmsft
isvargasmsft / callingAPI.php
Created November 7, 2023 21:13
Calling the demo API with PHP
<?php
use KiotaPosts\Client\PostsApiClient;
use KiotaPosts\Client\Models\Post;
use Microsoft\Kiota\Abstractions\ApiException;
use Microsoft\Kiota\Abstractions\Authentication\AnonymousAuthenticationProvider;
use Microsoft\Kiota\Http\GuzzleRequestAdapter;
require __DIR__.'/vendor/autoload.php';
@isvargasmsft
isvargasmsft / generateAPIclientPHP.bash
Created November 7, 2023 21:10
Generate a PHP API client with Kiota
kiota generate -l PHP -d https://raw.githubusercontent.com/microsoft/kiota-samples/main/get-started/quickstart/posts-api.yml -c PostsApiClient -n KiotaPosts\Client -o ./client
@isvargasmsft
isvargasmsft / KiotaPHPDependencies.bash
Created November 7, 2023 21:09
Commands to install dependencies to generate PHP API Clients with Kiota
composer require microsoft/kiota-abstractions
composer require microsoft/kiota-http-guzzle
composer require microsoft/kiota-serialization-json
composer require microsoft/kiota-serialization-text
@isvargasmsft
isvargasmsft / installKiota.bash
Last active November 7, 2023 21:08
Command to install Kiota as a .NET tool
dotnet tool install --global Microsoft.OpenApi.Kiota
@isvargasmsft
isvargasmsft / callAPI.py
Created November 7, 2023 20:57
Calling the JSON Placeholder API
import asyncio
from kiota_abstractions.authentication.anonymous_authentication_provider import (
AnonymousAuthenticationProvider)
from kiota_http.httpx_request_adapter import HttpxRequestAdapter
from client.posts_client import PostsClient
from client.models.post import Post
async def main():
# You may need this if your're using asyncio on windows
# See: https://stackoverflow.com/questions/63860576
@isvargasmsft
isvargasmsft / generateAPIclientPython.bash
Last active November 7, 2023 21:11
CLI command to generate Python API clients with Kiota
kiota generate -l python -c PostsClient -n client -d https://raw.githubusercontent.com/microsoft/kiota-samples/main/get-started/quickstart/posts-api.yml -o ./client
@isvargasmsft
isvargasmsft / pythondependencies.bash
Created November 7, 2023 20:52
CLI commands to install Python dependencies for Kiota
pip install microsoft-kiota-abstractions
pip install microsoft-kiota-http
pip install microsoft-kiota-serialization-json
pip install microsoft-kiota-serialization-text
@isvargasmsft
isvargasmsft / app-only.py
Created October 12, 2023 16:03
Python simple initialization
import asyncio
from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
credential = ClientSecretCredential(
'tenant_id',
'client_id',
'client_secret'
)
scopes = ['https://graph.microsoft.com/.default']
@isvargasmsft
isvargasmsft / app-only.php
Created October 10, 2023 17:23
PHP simple initialization
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Kiota\Abstractions\ApiException;
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
set_include_path(__DIR__);
require 'vendor/autoload.php';
$tokenRequestContext = new ClientCredentialContext(
'tenantID',
@isvargasmsft
isvargasmsft / composer.json
Created July 10, 2023 21:40
Upgrade to a new RC version
{
"name": "isvargasmsft/phpdemoapp",
"description": "This is an app for demos",
"authors": [
{
"name": "y"
}
],
"minimum-stability": "RC",
"require": {