Share links hitting auth error - microsoft-graph-api

I am trying to access sharing links via the Graph API. Following the below page to access the images https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/shares_get
I am hitting an auth error on this URL: https://graph.microsoft.com/v1.0/shares/u!aHR0cHM6Ly9vbmVkcml2ZS5saXZlLmNvbS9yZWRpcj9yZXNpZD0xNUI2OEIxRjRCMUMyNTAzITMyOCZhdXRoa2V5PSFBSUNfRGZ1YnpGa20zazAmdj0zJml0aGludD1waG90byUyY3BuZw/root?$expand=children
The same link but using the OneDrive API works: https://api.onedrive.com/v1.0/shares/u!aHR0cHM6Ly9vbmVkcml2ZS5saXZlLmNvbS9yZWRpcj9yZXNpZD0xNUI2OEIxRjRCMUMyNTAzITMyOCZhdXRoa2V5PSFBSUNfRGZ1YnpGa20zazAmdj0zJml0aGludD1waG90byUyY3BuZw/root?$expand=children
Have I missed any steps on converting the URL? From what I can tell the documentation is the same across both Graph and OneDrive APIs.

Related

Is there a way to create a static public URL for an image in my personal OneDrive using Microsoft Graph API?

What I'm trying to achieve via Microsoft Graph API is to upload an image to my personal OneDrive and get a URL which my code will then send to someone else to view at a later date. This URL must require no authentication and must able to be used in an img tag for a website.
I've managed to upload the image and use the /thumbnails endpoint to get the URL but it seems like the URL expires after some time (I think around 24 hrs). I have also tried:
using the /content endpoint - that also created a short-lived URL.
using the /createLink endpoint then encoding the URL and using the /shares endpoint - that also created a short-lived URL.
So...anybody know of any alternatives to create a non-expiring public URL for images on personal OneDrive accounts using Microsoft Graph API?
Many thanks in advance!

Read data from Youtube Analytics API without Oauth2

I am currently writing a python script to pull information from YouTube Analytics API for a list of separate YouTube channels. The output would be, for example, count video views for each YouTube channel in last month.
My initial idea was to ask each of the YouTube account owners to create a YouTube Analytics app in their console.cloud.google, create a Project, enable the youTube Analytics API, generate an API key and specify that it is needed for the YouTube Analytics API.
I'm testing with one account and if I try to run the script using the API Key generated with the process described above and authenticating like this:
def get_service():
return build('youtubeAnalytics', 'v2', developerKey=API_KEY)
it fails with a HttpError 401 Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
I am not sure if I have done something wrong in creating the API key, or if instead the YouTube Analytics API requires Oauth2 authentication. If the latter is the case, then I am surprised that google console lets you to go all the way and generate API keys and specify that they are needed for the YouTube Analytics API, only for you to find out that you can't use it.
So my question is: do I have to use Oauth2 for YouTube Analytics API or can I use the API key? I'm trying to read data from "my own" account, so why do I need to manually authorise my own app?
Ok I found out that it is not possible to use YouTube Analytics API without OAuth 2.0 authentication. The Google docs and the Google console are very confusing in my opinion as they respectively allow you to create API keys specific for YouTube Analytics API and describe API keys as a possible way to authenticate (only to tell you after that, that all methods require OAuth2.0).
I'm still unclear on how to setup YouTube Analytics API authentication for a command-line python script that does not require users to give manually consent every time the script runs.
I will open a separate question for that.
Set key parameter. You can read data with api key. It's simple.
http -v 'https://www.googleapis.com/youtube/v3/playlistItems?playlistId={playlistId}&part=id,snippet,contentDetails,status&key={api_key}&max_results=10'

Outlook api. How to search emails with oauth token?

Is there any working and complete code samples that demonstrate how to work with hotmail api?
For example I've already made for gmail api with web application:
oAuth
search mail by uuid inside mail body
get Message Content
get Message Attachment
some processing code
Now I need to integrate hotmail.
done only:
oAuth with scope https://graph.microsoft.com/mail.read
That code samples that I found in official documentation doesn't shows how to pass oauth token - thats why have a lot of questions
Share some links that will help me, please!
I recommend you use the Microsoft Graph to read and search emails. It works for work, school and personal Microsoft accounts (hotmail, live, outlook.com, etc).
Since you already have an access token, just pass it through with an Authorization header. More information about using access tokens with the Microsoft Graph can be found in their documentation.
Authorization: Bearer [Access Token]
For searching email, try the following query:
GET https://graph.microsoft.com/v1.0/me/messages?$search="hello world". If you're trying to search for emails in a different user's mail, try:
GET https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/messages?$search=foobar
I also recommend trying the Microsoft Graph Explorer since it has sample queries for Outlook Mail. To show the Outlook samples, click the show more samples link. Also, clicking the icon to the right of each query will bring you to the documentation page for that sample.

"accessNotConfigured" error occurred using Youtube API v3

I have been struggled with Youtube API and now I am stuck.
What I did is:
create a project at google developers console(https://console.developers.google.com)
enabled "YouTube Data API v3"
generate api key of iOS.
access to https://www.googleapis.com/youtube/v3/search?key={API KEY}&part=id&q=soccer by web browser and got the error message
Am I missing something?
I have read many questions but I cannot solved yet.
In step 3 "generate API key for IOS", the comment on the Google Developer Console web page says
Use of this key does not require any user action or consent, does not grant access
to any account information, and is not used for authorization.
Clicking on the *Learn More" button, it says:
Use an API key when your application is running on a server and accessing one of the following kinds of data:
•Data that the data owner has identified as public, such as a public calendar or blog.
•Data that is owned by a Google service such as Google Maps or Google Translate. (Access limitations may apply.)
I think you need to use the OAuth process rather than the API Key. Click on Learn More in the OAuth section of the Developer Console web page to learn about using OAuth with Apple iOS.
To create oAuth credentials for iOS:
Create new Client ID / Installed Application / iOS
I know it sounds a bit elementary, but I solved this same problem by going back into Google developer, creating a whole new project, new API key, and then it worked. Google quirk??

oauth 2 skydrive access in asp.net web page

I would like to access skyDrive using REST in my website. I want to retrieve list of files and folders, download, upload and delete files.
I've got a microsoft live management site- clientID and clientSecret.
I am trying to figure out the reason of getting 400 bad request error
While trying to get access token, refresh token from live services.
I have also followed sample from Github but still having same issue.
https://github.com/liveservices/LiveSDK-for-Windows/tree/master/src/Web/Samples/OAuthServer/Asp.net/OAuthSample
I can forward rest of code if someone thinks can able to resolve it.
Thank you
Thanks a lot!

Resources