stevenmaguire / oauth2-salesforce

Salesforce Provider for the OAuth 2.0 Client
MIT License
31 stars 13 forks source link

Expand documentation on token generation. #14

Closed AJRepo closed 3 years ago

AJRepo commented 3 years ago

I'm reading the documentation for this project and seeing the line:

$existingAccessToken = getAccessTokenFromYourDataStore();

As someone new to this library, this was very confusing.

Just some notes for others who might see this and also get confused:

The "getAccessTokenFromYourDataStore()" is a shortened phrase for "use some token generating function".

There is one

$provider->getAccessToken('password', ['username'=>'USERNAME', 'password' => 'PASSWORD']);

Using the salesforce sandbox (test.salesforce.com), the return from salesforce is a JSON string

{
"access_token":"REDACTED",
"instance_url":"REDACTED.my.salesforce.com",
"id":"https://test.salesforce.com/id/REDACTED",
"token_type":"Bearer",
"issued_at":"REDACTED",
"signature":"REDACTED"
}

which this library encodes into this object

Stevenmaguire\OAuth2\Client\Token\AccessToken Object
(
    [instanceUrl:Stevenmaguire\OAuth2\Client\Token\AccessToken:private] => https://REDACTED.my.salesforce.com
    [accessToken:protected] => REDACTED
    [expires:protected] => 
    [refreshToken:protected] => 
    [resourceOwnerId:protected] => https://test.salesforce.com/id/REDACTED
    [values:protected] => Array
        (
            [instance_url] => https://REDACTED.my.salesforce.com
            [id] => https://test.salesforce.com/id/REDACTED
            [token_type] => Bearer
            [issued_at] => REDACTED
            [signature] => REDACTED
        )
)

Let me know if you want me to update the documentation with something similar to this longer explanation. If not, you can close this ticket. I'll close it if I don't hear back.

AJRepo commented 3 years ago

Closing ticket. See Pull request https://github.com/stevenmaguire/oauth2-salesforce/pull/15