You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
require'adal'require'microsoft_graph'# Code from exampleusername='admin@tenant.onmicrosoft.com'password='xxxxxxxxxxxx'client_id='xxxxx-xxxx-xxx-xxxxxx-xxxxxxx'client_secret='xxxXXXxxXXXxxxXXXxxXXXXXXXXxxxxxx='tenant='tenant.onmicrosoft.com'user_cred=ADAL::UserCredential.new(username,password)client_cred=ADAL::ClientCredential.new(client_id,client_secret)context=ADAL::AuthenticationContext.new(ADAL::Authority::WORLD_WIDE_AUTHORITY,tenant)resource="https://graph.microsoft.com"tokens=context.acquire_token_for_user(resource,client_cred,user_cred)# add the access token to the request headercallback=Proc.new{ |r| r.headers["Authorization"]="Bearer #{tokens.access_token}"}graph=MicrosoftGraph.new(base_url: "https://graph.microsoft.com/v1.0",cached_metadata_file: File.join(MicrosoftGraph::CACHED_METADATA_DIRECTORY,"metadata_v1.0.xml"),api_version: '1.6',# Optional
&callback)me=graph.me# get the current user# CUSTOM CODEfirst_inbox_message=me.mail_folders.find('inbox').messages.firstfirst_inbox_message.attachments.first# => RuntimeError
To reproduce:
Question: Why
RuntimeErrorwas added here ?I've replaced
raise RuntimeErrorwithvaluefor myself and it works brilliant