stevenmaguire / oauth2-salesforce

Salesforce Provider for the OAuth 2.0 Client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expand documentation on token generation.

AJRepo opened this issue · comments

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.

Closing ticket. See Pull request #15