Coder Social home page Coder Social logo

microsoftgraph / php-connect-sample Goto Github PK

View Code? Open in Web Editor NEW
52.0 15.0 21.0 212 KB

[ARCHIVED] Use Microsoft Graph to access a user’s Microsoft account data from within a PHP web application. This sample gets OAuth tokens from the Azure AD v2.0 endpoint and connects it to the Microsoft Graph SDK for PHP.

PHP 89.55% JavaScript 1.23% Vue 0.61% HTML 8.62%
devxsample

php-connect-sample's Introduction

[ARCHIVED] Microsoft Graph Connect Sample for PHP

IMPORTANT

This project is being archived and replaced with the Build PHP apps with Microsoft Graph. As part of the archival process, we're closing all open issues and pull requests.

You can continue to use this sample "as-is", but it won't be maintained moving forward. We apologize for any inconvenience.

This sample shows how to connect a PHP web app to a Microsoft work or school (Azure Active Directory) or personal (Microsoft) account using the Microsoft Graph API to send an email. It uses the Microsoft Graph PHP Client Library to work with data returned by Microsoft Graph. In addition, the sample uses the Office Fabric UI for styling and formatting the user experience.

PHP Connect sample screenshot

Prerequisites

This sample requires the following:

  • Either a Microsoft account or Office 365 for Business account. You can sign up for an Office 365 Developer subscription that includes the resources that you need to start building Office 365 apps.
  • PHP 5.6^ or 7
  • Composer, a dependency manager for PHP

Register the application

  1. Sign in to the App Registration Portal using either your personal, work, or school account.

  2. Choose Add an app

  3. Enter a name for the app and choose Create application.

    The registration page displays, listing the properties of your app.

  4. Copy the Application ID. This is the unique identifier for your app.

  5. Under Application Secrets, choose Generate New Password. Copy the password from the New password generated dialog.

    You'll use the application ID and password to configure the sample app in the next section.

  6. Upder Platforms, choose Add platform.

  7. Choose Web.

  8. Make sure the Allow Implicit Flow check box is selected, and enter http://localhost:8000/oauth.php as the Redirect URI.

    The allow Implicit Flow option enables the hybrid flow. During authentication, this enables the app to receive both sign-in info (the id_token) and artifacts (in this case, an authorization code) that the app can use to obtain an access token.

  9. Choose Save.

Configure and run the sample

  1. Download or clone the Microsoft Graph Connect Sample for PHP

  2. Open the sample solution in your favorite IDE.

  3. In the graph.php file in the config directory, replace the ENTER_YOUR_CLIENT_ID and ENTER_YOUR_SECRET placeholder values with the application ID and password you copied during registration.

  4. Install the project's dependencies:

    composer install

  5. Rename .env.example to .env and run php artisan key:generate

  6. Run php artisan serve to run the sample.

  7. Navigate to http://localhost:8000 in your web browser.

  8. Sign in with your account and grant the requested permissions.

  9. Choose the Get email address button. When the operation completes, the email address of the signed-in user is displayed on the page.

  10. Optionally edit the recipient list and email subject, and then choose the Send email button. When the mail is sent, a success message is displayed below the button.

Troubleshooting

Error: Unable to get local issuer certificate

You receive the following error after providing your credentials to the sign in page.

SSL certificate problem: unable to get local issuer certificate

cURL can't verify the validity of the Microsoft certificate when trying to issue a request call to get tokens. You must configure cURL to use a certificate when issuing https requests by following these steps:

  1. Download the cacert.pem file from cURL website.

  2. Open your php.ini file and add the following line

    curl.cainfo = "path_to_cacert/cacert.pem"
    

What's Next?

This sample helps get you registered and making calls to Microsoft Graph. You can now try different calls using the Microsoft Graph library for PHP. Explore the Microsoft Graph documentation to see what you can do with your favorite Microsoft products. You can try:

  1. Copying a OneDrive file to another folder
  2. Performing cell functions with Excel
  3. Navigating your organization's directory
  4. Paging through a list of emails

Contributing

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Questions and comments

We'd love to get your feedback about the PHP Connect sample. You can send your questions and suggestions to us in the Issues section of this repository.

Questions about Microsoft Graph development in general should be posted to Stack Overflow. Make sure that your questions or comments are tagged with [MicrosoftGraph] and [API].

Additional resources

Copyright

Copyright (c) 2016 Microsoft. All rights reserved.

php-connect-sample's People

Contributors

iampoul avatar jasonjoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-connect-sample's Issues

Response to OAuth2 Provider Authorization returns a second Login page

So far I have managed to successfully use the demo app to Connect to an Office365 Account, use the Microsoft Login page and sign in with the account and send the test email.... All perfect.

When I have tried to implement the code in my own app, I'm having trouble getting the access token.
It would appear that the response to the request for the Authorization Token returns a second login page.

The example app, with the same configuration variables returns a parsed array from the API, but when copied into my own application, the request returns a login screen.

As there is no specific error message from the Microsoft API (its just a login page) it is very difficult to debug. The exception that is thrown is AbstractProvider::prepareAccessTokenResponse() must be of the type array, string given, called in php myproject\vendor\league\oauth2-client\src\Provider\AbstractProvider.php on line 52

When I add a breakpoint in the line above I can see the $response variable is

<!DOCTYPE html>
<html dir="ltr" class="" lang="en">
<head>
    <title>Sign in to your account</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta name="PageID" content="ConvergedError" />
    <meta name="SiteID" content="" />
    <meta name="ReqLC" content="1033" />
    <meta name="LocLC" content="en-US" />

    <noscript>
        <meta http-equiv="Refresh" content="0; URL=" />
    </noscript>

    
        <link rel="shortcut icon" href="https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/content/images/favicon_a.ico" />
    
    <meta name="robots" content="none" />

<script type="text/javascript">//<![CDATA[
$Config={"strHeaderText":"Sign in","unsafe_strTopMessage":"Sorry, but we’re having trouble signing you in.","strMainMessage":"We received a bad request.","strAdditionalMessage":"","strServiceExceptionMessage":"AADSTS90056: This endpoint only accepts POST, OPTIONS requests. Received a GET request.","strTraceId":"d8444ef7-293f-4057-8975-0bc8bc3d0500","strErrorCode":90056,"iHttpErrorCode":400,"iViewId":1,"urlCancel":"","strTimestamp":"2018-06-14T07:59:37Z","iMaxStackForKnockoutAsyncComponents":10000,"strCopyrightTxt":"\u0026#169;2018 Microsoft","fShowButtons":true,"fShowDogfoodBanner":false,"urlCdn":"https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/","urlFooterTOU":"https://www.microsoft.com/en-US/servicesagreement/","urlFooterPrivacy":"https://privacy.microsoft.com/en-US/privacystatement","iPawnIcon":0,"sPOST_Username":"","sFTName":"flowToken","dynamicTenantBranding":null,"oAppCobranding":{},"iBackgroundImage":0,"fUseConstantPolling":true,"fUseFlowTokenAsCanary":true,"fApplicationInsightsEnabled":false,"iApplicationInsightsEnabledPercentage":0,"fRepositionFooterButtons":false,"fUseTextOnlyIdentityBannerWithBack":false,"fUseSigninSubtitle":false,"urlSetDebugMode":"https://login.microsoftonline.com/common/debugmode","scid":1013,"hpgact":1801,"hpgid":1117,"pgid":"ConvergedError","apiCanary":"AQABAAAAAADX8GCi6Js6SK82TsD2Pb7rjSZZBBLpcZL6aajP1EU2xivzJcl9J0-eWJzy_zyynpM-ibdfeiLggakoCmAkSnvrnaP1VRq39cjRQ2j5DuysRvda2Q-BQT7k_TSKc5gWFIyZbdc46n-JN47VCaCWh4ehtQvQg-6Ix6rdjFVdtaap_HjzFZrNaGaNJypJ1_s9yBX2OA2yFpWflYa5X_i4_zoqPKvLFhGs7o4Ym2hKYFV2CSAA","canary":"ALkDT++Ytaso98LIv/oFsy2Lt01LVvEDmMialCkKuxk=5:1","correlationId":"758e8d24-758c-4e97-a8ac-12198d9f1886","sessionId":"d8444ef7-293f-4057-8975-0bc8bc3d0500","locale":{"mkt":"en-US","lcid":1033},"slMaxRetry":2,"slReportFailure":true,"strings":{"desktopsso":{"authenticatingmessage":"Trying to sign you in"}},"enums":{"ClientMetricsModes":{"None":0,"SubmitOnPost":1,"SubmitOnRedirect":2,"InstrumentPlt":4}},"urls":{"instr":{"pageload":"https://login.microsoftonline.com/common/instrumentation/reportpageload","dssostatus":"https://login.microsoftonline.com/common/instrumentation/dssostatus"}},"browser":{"ltr":1,"_Other":1,"Full":1,"RE_Other":1,"b":{"name":"Other","major":-1,"minor":-1},"os":{"name":"Unknown","version":""},"V":-1},"watson":{"url":"/common/handlers/watson","bundle":"https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/content/cdnbundles/watson.min.js","sbundle":"https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/content/cdnbundles/watsonsupport.min.js","fbundle":"https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/content/cdnbundles/frameworksupport.min.js","resetErrorPeriod":5,"maxCorsErrors":-1,"maxInjectErrors":5,"maxErrors":10,"maxTotalErrors":3,"expSrcs":["https://secure.aadcdn.microsoftonline-p.com/ests/","https://login.microsoftonline.com",".login.microsoftonline.com"],"envErrorRedirect":true,"envErrorUrl":"/common/handlers/enverror"},"loader":{"cdnRoots":[]},"serverDetails":{"slc":"ProXXXXes","dc":"DUB2","ri":"ESTXXXX_74","ver":{"v":[2,1,7758,23]},"rt":"2018-06-14T07:59:37","et":1},"fBreakBrandingSigninString":true};
//]]></script> 
<script type="text/javascript">//<![CDATA[
!function(){var e=window,r=e.$Debug=e.$Debug||{},n=e.$Config||{};if(!r.appendLog){var t=[],o=0;r.appendLog=function(e){var r=n.maxDebugLog||25,a=(new Date).toUTCString()+":"+e;t.push(o+":"+a),t.length>r&&t.shift(),o++},r.getLogs=function(){return t}}}(),function(){function e(e,r){function n(a){var i=e[a];return t-1>a?void(o.r[i]?n(a+1):o.when(i,function(){n(a+1)})):void r(i)}var t=e.length;n(0)}function r(e,r,a){function i(){var e=!!s.method,o=e?s.method:a[0],i=s.extraArgs||[],u=t.$WebWatson;try{var c=n(a,!e);if(i&&i.length>0)for(var l=i.length,d=0;l>d;d++)c.push(i[d]);o.apply(r,c)}catch(f){return void(u&&u.submitFromException&&u.submitFromException(f))}}var s=o.r&&o.r[e];return r=r?r:this,s&&(s.skipTimeout?i():t.setTimeout(i,0)),s}function n(e,r){return Array.prototype.slice.call(e,r?1:0)}var t=window;t.$Do||(t.$Do={q:[],r:[],removeItems:[],lock:0,o:[]});var o=t.$Do;o.when=function(n,t){function a(e){r(e,i,s)||o.q.push({id:e,c:i,a:s})}var i=0,s=[],u=1,c="function"==typeof t;c||(i=t,u=2);for(var l=u;l<arguments.length;l++)s.push(arguments[l]);n instanceof Array?e(n,a):a(n)},o.register=function(e,n,t){if(!o.r[e]){o.o.push(e);var a={};if(n&&(a.method=n),t&&(a.skipTimeout=t),arguments&&arguments.length>3){a.extraArgs=[];for(var i=3;i<arguments.length;i++)a.extraArgs.push(arguments[i])}o.r[e]=a,o.lock++;try{for(var s=0;s<o.q.length;s++){var u=o.q[s];u.id==e&&r(e,u.c,u.a)&&o.removeItems.push(u)}}catch(c){throw c}finally{if(o.lock--,0===o.lock){for(var l=0;l<o.removeItems.length;l++)for(var d=o.removeItems[l],f=0;f<o.q.length;f++)if(o.q[f]===d){o.q.splice(f,1);break}o.removeItems=[]}}}},o.unregister=function(e){o.r[e]&&delete o.r[e]}}(),function(){function e(e,r){var n=c.$Debug;n&&n.appendLog&&(r&&(e+=" '"+(r.src||r.href||"")+"'",e+=", id:"+(r.id||""),e+=", async:"+(r.async||""),e+=", defer:"+(r.defer||"")),n.appendLog(e))}function r(){var e=c.$Config||{},r=e.loader||{};return r.slReportFailure||e.slReportFailure||!1}function n(){var e=c.$Config||{},r=e.loader||{};return r.redirectToErrorPageOnLoadFailure||!1}function t(e){var r=e.indexOf("?"),n=r>-1?r:e.length;return n>f&&e.substr(n-f,f).toLowerCase()===d}function o(e,r,n){var o=t(e)?a(e):i(e);return r&&(o.id=r),"function"==typeof o.setAttribute&&(o.setAttribute("crossorigin","anonymous"),n&&"string"==typeof n&&o.setAttribute("integrity",n)),o}function a(e){var r=l.createElement("link");return r.rel="stylesheet",r.type="text/css",r.href=e,r}function i(e){var r=l.createElement("script");return r.type="text/javascript",r.src=e,r.defer=!1,r.async=!1,r}function s(e){var r=!0,n=e.src||e.href||"";if(n){if(t(n))try{e.sheet&&e.sheet.cssRules&&!e.sheet.cssRules.length&&(r=!1)}catch(o){}}else r=!1;return r}function u(){function r(e){if(!(u&&u.length>1))return e;for(var r=0;r<u.length;r++)if(e.startsWith(u[r]))return u[r+1<u.length?r+1:0]+e.substring(u[r].length);return e}function n(t,i,u){if(t<f.length){var c=f[t];if(!c||!c.srcPath)return void n(t+1,i,u);c.retry>0&&(c.srcPath=r(c.srcPath),c.origId||(c.origId=c.id),c.id=c.origId+"_Retry_"+c.retry);var g=o(c.srcPath,c.id,c.integrity),h=function(){return e("[$Loader]: "+(d.failMessage||"Failed"),g),c.retry<a?(c.retry++,void n(t,i,u)):void(u&&u())},v=function(){s(g)?(e("[$Loader]: "+(d.successMessage||"Loaded"),g),n(t+1,i,u)):h()};g.onload=v,g.onerror=h,g.onreadystatechange=function(){"loaded"===g.readyState?setTimeout(v,500):"complete"===g.readyState&&v()};var p=l.getElementsByTagName("head")[0];p.appendChild(g),e("[$Loader]: Loading '"+(c.srcPath||"")+"', id:"+(c.id||""))}else i&&i()}var t=c.$Config||{},a=t.slMaxRetry||2,i=t.loader||{},u=i.cdnRoots||[],d=this,f=[];d.retryOnError=!0,d.successMessage="Loaded",d.failMessage="Error",d.Add=function(e,r,n,t){e&&f.push({srcPath:e,id:r,retry:t||0,integrity:n})},d.AddLoaded=function(){},d.AddForReload=function(e){var r=e.src||e.href||"";d.Add(r,"AddForReload",e.integrity,1)},d.AddIf=function(e,r,n){e&&d.Add(r,n)},d.Load=function(e,r){n(0,e,r)}}var c=window,l=c.document,d=".css",f=d.length;u.On=function(e,r){if(!e)throw"The target element must be provided and cannot be null.";r?u.OnError(e):u.OnSuccess(e)},u.OnSuccess=function(t,o,a){var i=t.src||t.href||"",c=r(),l=n();if(!t)throw"The target element must be provided and cannot be null.";if(s(t)){e("[$Loader]: Loaded",t);var d=new u;d.failMessage="Reload Failed",d.successMessage="Reload Success",d.AddLoaded(t,o,a),d.Load(null,function(){if(c)throw"Unexpected state. resourceLoader.Load() failed despite initial load success. ['"+i+"']";l&&(document.location.href="/error.aspx?err=504")})}else u.OnError(t,o,a)},u.OnError=function(t,o,a){var i=t.src||t.href||"",s=r(),c=n();if(!t)throw"The target element must be provided and cannot be null.";e("[$Loader]: Failed",t);var l=new u;l.failMessage="Reload Failed",l.successMessage="Reload Success",l.AddForReload(t,o,a),l.Load(null,function(){if(s)throw"Failed to load external resource ['"+i+"']";c&&(document.location.href="/error.aspx?err=504")})},c.$Loader=u}(),function(){function e(){if(!$){var e=new v.$Loader;e.AddIf(!v.jQuery,y.sbundle,"WebWatson_DemandSupport"),y.sbundle=null,delete y.sbundle,e.AddIf(!v.$Api,y.fbundle,"WebWatson_DemandFramework"),y.fbundle=null,delete y.fbundle,e.Add(y.bundle,"WebWatson_DemandLoaded"),e.Load(r,n),$=!0}}function r(){if(v.$WebWatson){if(v.$WebWatson.isProxy)return void n();m.when("$WebWatson.full",function(){for(;b.length>0;){var e=b.shift();e&&v.$WebWatson[e.cmdName].apply(v.$WebWatson,e.args)}})}}function n(){var e=v.$WebWatson?v.$WebWatson.isProxy:!0;if(e){if(!w&&JSON){try{var r=new XMLHttpRequest;r.open("POST",y.url),r.setRequestHeader("Accept","application/json"),r.setRequestHeader("Content-Type","application/json; charset=UTF-8"),r.setRequestHeader("canary",p.apiCanary),r.setRequestHeader("client-request-id",p.correlationId),r.setRequestHeader("hpgid",p.hpgid||0),r.setRequestHeader("hpgact",p.hpgact||0);for(var n=-1,o=0;o<b.length;o++)if("submit"===b[o].cmdName){n=o;break}var a=b[n]?b[n].args||[]:[],i={sr:y.sr,ec:"Failed to load external resource [Core Watson files]",wec:55,idx:1,pn:p.pgid||"",sc:p.scid||0,hpg:p.hpgid||0,msg:"Failed to load external resource [Core Watson files]",url:a[1]||"",ln:0,ad:0,an:!1,cs:"",sd:p.serverDetails,ls:null,diag:h(y)};r.send(JSON.stringify(i))}catch(s){}w=!0}y.loadErrorUrl&&window.location.assign(y.loadErrorUrl)}t()}function t(){b=[],v.$WebWatson=null}function o(r){return function(){var n=arguments;b.push({cmdName:r,args:n}),e()}}function a(){var e=["foundException","resetException","submit"],r=this;r.isProxy=!0;for(var n=e.length,t=0;n>t;t++){var a=e[t];a&&(r[a]=o(a))}}function i(e,r,n,t,o,a,i){var s=v.event;a||(a=d(o||s,i?i+2:2)),v.$Debug&&v.$Debug.appendLog&&v.$Debug.appendLog("[WebWatson]:"+(e||"")+" in "+(r||"")+" @ "+(n||"??")),W.submit(e,r,n,t,o||s,a,i)}function s(e,r){return{signature:e,args:r,toString:function(){return this.signature}}}function u(e){for(var r=[],n=e.split("\n"),t=0;t<n.length;t++)r.push(s(n[t],[]));return r}function c(e){for(var r=[],n=e.split("\n"),t=0;t<n.length;t++){var o=s(n[t],[]);n[t+1]&&(o.signature+="@"+n[t+1],t++),r.push(o)}return r}function l(e){if(!e)return null;try{if(e.stack)return u(e.stack);if(e.error){if(e.error.stack)return u(e.error.stack)}else if(window.opera&&e.message)return c(e.message)}catch(r){}return null}function d(e,r){var n=[];try{for(var t=arguments.callee;r>0;)t=t?t.caller:t,r--;for(var o=0;t&&L>o;){var a="InvalidMethod()";try{a=t.toString()}catch(i){}var u=[],c=t.args||t.arguments;if(c)for(var d=0;d<c.length;d++)u[d]=c[d];n.push(s(a,u)),t=t.caller,o++}}catch(i){n.push(s(i.toString(),[]))}var f=l(e);return f&&(n.push(s("--- Error Event Stack -----------------",[])),n=n.concat(f)),n}function f(e){if(e)try{var r=/function (.{1,})\(/,n=r.exec(e.constructor.toString());return n&&n.length>1?n[1]:""}catch(t){}return""}function g(e){if(e)try{if("string"!=typeof e&&JSON&&JSON.stringify){var r=f(e),n=JSON.stringify(e);return n&&"{}"!==n||(e.error&&(e=e.error,r=f(e)),n=JSON.stringify(e),n&&"{}"!==n||(n=e.toString())),r+":"+n}}catch(t){}return""+(e||"")}function h(e){var r=[];try{if(jQuery?(r.push("jQuery v:"+jQuery().jquery),r.push(jQuery.easing?"jQuery.easing:"+JSON.stringify(jQuery.easing):"jQuery.easing is not defined")):r.push("jQuery is not defined"),e&&e.expectedVersion&&r.push("Expected jQuery v:"+e.expectedVersion),m){var n,t="";for(n=0;n<m.o.length;n++)t+=m.o[n]+";";for(r.push("$Do.o["+t+"]"),t="",n=0;n<m.q.length;n++)t+=m.q[n].id+";";r.push("$Do.q["+t+"]")}if(v.$Debug&&v.$Debug.getLogs){var o=v.$Debug.getLogs();o&&o.length>0&&(r=r.concat(o))}if(b)for(var a=0;a<b.length;a++){var i=b[a];if(i&&"submit"===i.cmdName)try{if(JSON&&JSON.stringify){var s=JSON.stringify(i);s&&r.push(s)}}catch(u){r.push(g(u))}}}catch(c){r.push(g(c))}return r}var v=window,p=v.$Config||{},y=p.watson,m=v.$Do;if(!v.$WebWatson&&y){var b=[],$=!1,w=!1,L=10,W=v.$WebWatson=new a;W.CB={},W._orgErrorHandler=v.onerror,v.onerror=i,W.errorHooked=!0,m.when("jQuery.version",function(e){y.expectedVersion=e}),m.register("$WebWatson")}}(),function(){function e(e,r){for(var n=r.split("."),t=n.length,o=0;t>o&&null!==e&&void 0!==e;)e=e[n[o++]];return e}function r(r){var n=null;return null===u&&(u=e(a,"Constants")),null!==u&&r&&(n=e(u,r)),null===n||void 0===n?"":n.toString()}function n(n){var t=null;return null===i&&(i=e(a,"$Config.strings")),null!==i&&n&&(t=e(i,n.toLowerCase())),(null===t||void 0===t)&&(t=r(n)),null===t||void 0===t?"":t.toString()}function t(e,r){var t=null;return e&&r&&r[e]&&(t=n("errors."+r[e])),t||(t=n("errors."+e)),t||(t=n("errors."+c)),t||(t=n(c)),t}function o(n){var t=null;return null===s&&(s=e(a,"$Config.urls")),null!==s&&n&&(t=e(s,n.toLowerCase())),(null===t||void 0===t)&&(t=r(n)),null===t||void 0===t?"":t.toString()}var a=window,i=null,s=null,u=null,c="GENERIC_ERROR";a.GetString=n,a.GetErrorString=t,a.GetUrl=o}(),function(){var e=window,r=e.$Config||{};e.$B=r.browser||{}}();

//]]></script> 



    <script type="text/javascript">
        ServerData = $Config;
    </script>

    
<link crossorigin="anonymous" href="https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/content/cdnbundles/converged.login.min.css" rel="stylesheet" onerror='$Loader.On(this,true)' onload='$Loader.On(this)' integrity='sha384-xznjl5MWBmtr74oDcjcoEsoDik1lgcOweUsrT60BfsR6jwKU+GUeTndhop6vsuIN' />

    <script crossorigin="anonymous" src="https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/content/cdnbundles/convergederror_core.min.js" onerror='$Loader.On(this,true)' onload='$Loader.On(this)' integrity='sha384-lgSDRKhIffvDT8BSmPSbneJVdrOu/tKUmh6uRbf9nuR1xDv76fe4i3KXJ+75ScIo'></script>


    <script crossorigin="anonymous" src="https://secure.aadcdn.microsoftonline-p.com/ests/2.1.7758.23/content/cdnbundles/convergederrorstrings-en.min.js" onerror='$Loader.On(this,true)' onload='$Loader.On(this)' integrity='sha384-evfKROubLaYI40lsZRH/IKXjyZqDQI1y4ncuHg5TxmwYJHozqVZFllXPipP0jZ1k'></script>



</head>

<body data-bind="defineGlobals: ServerData, bodyCssClass" class="cb" style="display: none">
    <script type="text/javascript">//<![CDATA[
!function(){var e=window,o=e.document,i=e.$Config||{};if(e.self===e.top)o&&o.body&&(o.body.style.display="block");else if(!i.allowFrame){var s=e.self.location.href,l=s.indexOf("#"),n=-1!==l,t=s.indexOf("?"),f=n?l:s.length,d=-1===t||n&&t>l?"?":"&";s=s.substr(0,f)+d+"iframe-request-id="+i.sessionId+s.substr(f),e.top.location=s}}();

//]]></script>
</body>
</html>

Which appears to be another log in page.

Any Help would be appreciated.

At least one recipient isn't valid.

ClientException in RequestException.php line 111:
Client error: `POST https://graph.microsoft.com/v1.0/me/sendMail` resulted in a `400 Bad Request` response:
{
"error": {
"code": "ErrorInvalidRecipients",
"message": "At least one recipient isn't valid., A message c (truncated...)

I get this error when I ran a fresh copy the sample.

Uncaught exception for artisan

I was directed to here form the php REST sample, and tried installing this. However, when I get to php artisan key:generate, I get these errors:

Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Console\Kernel does not exist' in S:\htdocs\vendor\laravel\framework\src\Illuminate\Container\Container.php:749
Stack trace:
#0 S:\htdocs\vendor\laravel\framework\src\Illuminate\Container\Container.php(749): ReflectionClass->__construct('App\Console\Ker...')
#1 S:\htdocs\vendor\laravel\framework\src\Illuminate\Container\Container.php(644): Illuminate\Container\Container->build('App\Console\Ker...', Array)
#2 S:\htdocs\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(709): Illuminate\Container\Container->make('App\Console\Ker...', Array)
#3 S:\htdocs\vendor\laravel\framework\src\Illuminate\Container\Container.php(231): Illuminate\Foundation\Application->make('App\Console\Ker...', Array)
#4 S:\htdocs\vendor\laravel\framework\src\Illuminate\Container\Container.php(746): Illuminate\Container\Container->Illuminate\Container{closure}(Object(Illuminate\Foundation\Application), Array)
#5 S:\htdocs\vendor\laravel\framework\src\ in S:\htdocs\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 749

Tokens

is there a way top update a token, because all the data is saved in session vars, so yo cant access to the funcion refreshToken.

Unable to complete step 8 of sample process

I keep getting a 500 Internal Server error (with a decidedly un-helpful message) after completing the process of granting permissions to the registered application:

ServerException in RequestException.php line 111:
Server error: `GET https://graph.microsoft.com/v1.0/me` resulted in a `500 Internal Server Error` response:
{
"error": {
"code": "UnknownError",
"message": "{\"Status\":500,\"Message\":\"All the offeractions povided (truncated...)

I tried deleting the first application I registered and completing the steps again but continued to get the same result.

The code and state values appear to be appropriate values in the redirect URL (back to localhost:8002/login).

The access_token is set as expected on the session and provided to the Graph object in the /email route.

Beta API returning ErrorAccessDenied

I am trying to access the beta API, specifically user_findrooms

My application is registered, and has the required permissions. The user is logged in and redirected correctly. Calls to the v1 API work.

When I try to call the beta API like this:

$graph = new Graph();
$graph->setApiVersion('beta');
$graph->setAccessToken($_SESSION['access_token']);

$rooms = $graph->createRequest("get", "/me/findRooms")
                        ->setReturnType(Model\EmailAddress::class)
                        ->execute();

Then I get the following error:

Client error: GET https://graph.microsoft.com/beta/me/findRooms resulted in a 403 Forbidden response:
{
"error": {
"code": "ErrorAccessDenied",
"message": "Access is denied. Check credentials and try again.",
(truncated...)

Easier Certificate Error Workaround

From the README:

Error: Unable to get local issuer certificate

You receive the following error after providing your credentials to the sign in page.

SSL certificate problem: unable to get local issuer certificate

cURL can't verify the validity of the Microsoft certificate when trying to issue a request call to get tokens. You must configure cURL to use a certificate when issuing https requests by following these steps:

  1. Download the cacert.pem file from cURL website.
  2. Open your php.ini file and add the following line
 curl.cainfo = "path_to_cacert/cacert.pem"

There's actually a much simpler way to solve this problem, which is worth using as an alternative.

  1. Add paragonie/certainty as a dependency.
  2. Use RemoteFetch to ensure the latest CACert bundle is available.

Certainty ensures that the downloaded CACert.pem file is cryptographically signed by our security team using Ed25519 and that the metadata is checked into an append-only cryptographic ledger. The sha256sum of each bundle is also published, so that it can be cross-correlated with the bundle shared by the cURL developers. We have a detailed write-up about its motivation and design, if you're interested.

In short: Given access to the Internet and a writable directory, it guarantees that the PHP program in question has the latest CACert.pem bundle installed and delivers them securely.

Failed to Listen on Localhost:8000

I am following Read me file step by step, I got many errors but fixed. Last one remaining at below.

C:\wamp64\www>php artisan key:generate
Application key [base64:xxx=] set successfully.

C:\wamp64\www>php artisan serve
Laravel development server started on http://localhost:8000/
[Sat Sep 15 23:16:33 2018] Failed to listen on localhost:8000 (reason: An attempt was made to access a socket in a way forbidden by its access permissions.
)

Function mcrypt_module_open() is deprecated

I just followed the guide. Using PHP 7.1.11 on Windows. Visiting localhost:8000 generates the "Connect to Microsoft Graph" button but clicking that results in:

ErrorException in AbstractMcryptMixer.php line 75: Function mcrypt_module_open() is deprecated

This is being generated by oauth.php.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.