title: How to make a simple SAML request with PHP?
body: <p>I have worked with PHP a lot before but I have never used SAML because I never had to connect to a remote server. I have been reading various tutorials, posts, and examples for days now I still am getting no where. I have read up on :</p>
  
  <ul>
  <li><a href="http://www.cs.ucsb.edu/~bultan/courses/595-W06/SAML.pdf" rel="nofollow noreferrer">UC Santa Barbra Lecture on SAML</a></li>
  <li><a href="https://onelogin.zendesk.com/entries/268420-saml-toolkit-for-php" rel="nofollow noreferrer">OneLogin example and guide</a></li>
  <li><a href="http://en.wikipedia.org/wiki/SAML_2.0#Authentication_Request_Protocol" rel="nofollow noreferrer">Wiki on SAML</a></li>
  <li><a href="http://docs.rackspace.com/loadbalancers/api/v1.0/clb-getting-started/content/Generating_Auth_Token.html" rel="nofollow noreferrer">Rackspace guide on Auth Tokens</a></li>
  <li><a href="https://rnd.feide.no/2007/12/10/example_saml_2_0_request_and_response/" rel="nofollow noreferrer">Fiede RnD Example</a></li>
  <li><a href="https://stackoverflow.com/questions/2094136/getting-started-with-saml-and-php">Getting started SAML and PHP</a></li>
  </ul>
  
  <p>But still no success. I think when I was reading up on Onelogin, SimpleSAMLphp, and Shibboleth I felt like I was in the wrong place because I feel downloading and unpacking huge files as stacks would be for a service provider... In this case I am the Identity Provider and I thought it would be as simple as just making some xml and sending it off; and looking for a response. Not needing these huge amounts of code but maybe I am mistaken. </p>
  
  <p>When I look at the xml most of it makes sense. For example:</p>
  
  <pre><code>&lt;saml:Assertion
  Version="2.0"
  ID=“_34234se72”
  IssueInstant="2005-04-01T16:58:33.173Z"&gt;
   &lt;saml:Issuer&gt;http://authority.example.com/&lt;/saml:Issuer&gt;
   &lt;ds:Signature&gt;...&lt;/ds:Signature&gt;
   &lt;saml:Subject&gt;
       &lt;saml:NameID format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"&gt;
          jygH5F90l
      &lt;/saml:NameID&gt;
   &lt;/saml:Subject&gt;
    &lt;saml:AuthnStatement
        AuthnInstant="2005-04-01T16:57:30.000Z"&gt;
          &lt;saml:AuthnContext&gt;
            &lt;saml:AuthnContextClassRef&gt;
              urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
            &lt;/saml:AuthnContextClassRef&gt;
          &lt;/saml:AuthnContext&gt;
     &lt;/saml:AuthnStatement&gt;
  &lt;/saml:Assertion&gt;
  </code></pre>
  
  <p>I think I understand the process of sending 'jygH5F901' as the 'NameID' but lines line urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport make little to no sense to me. Could someone please point me to a good guide on how to get started or at least in the right direction.</p>
  
  <p>All I need to do is:</p>
  
  <ol>
  <li>Get an Authorization Token</li>
  <li>Exchange the Authorization Token for an Access Token.</li>
  <li>Use that Access token to GET information from the service providers database.</li>
  </ol>
  
  <p>Any help would be greatly appreciated; I am completely new to SAML so I probably sound dumb; but if just anyone could link me to a thorough guide or example that explains the structure and has more copy-paste friendly work. I just need to get that connection, import data then once I can get a hold of those returned variables all the PHP stuff after is easy. Thanks for your time; and any effort will be greatly appreciated.</p>