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
The `OAuthServiceInterface` is an interface that defines the contract for an OAuth service. It provides methods for retrieving configuration, authorization URL, access token, and user data from an OAuth service.
160
+
161
+
### Usage
162
+
163
+
To use this interface, you need to create a class that implements it and provides the necessary functionality. Here's an example of how you can implement the `OAuthServiceInterface`:
164
+
165
+
```php
166
+
<?php
167
+
168
+
namespace Effectra\ThirdParty;
169
+
170
+
class MyOAuthService implements OAuthServiceInterface
171
+
{
172
+
// Implement the getConfig() method
173
+
public function getConfig(): array
174
+
{
175
+
// Return the configuration array for the OAuth service
176
+
}
177
+
178
+
// Implement the getAuthURL() method
179
+
public function getAuthURL(): string
180
+
{
181
+
// Return the authorization URL for the OAuth service
182
+
}
183
+
184
+
// Implement the getAccessToken() method
185
+
public function getAccessToken(string $code): string
186
+
{
187
+
// Get the access token for the OAuth service using the authorization code
188
+
}
189
+
190
+
// Implement the getUser() method
191
+
public function getUser(string $token): ?array
192
+
{
193
+
// Get the user data from the OAuth service using the access token
194
+
}
195
+
}
196
+
```
197
+
198
+
In the above example, you need to replace the placeholder methods with your actual implementation based on the OAuth service you are integrating with.
199
+
200
+
### Method Overview
201
+
202
+
#### `getConfig(): array`
203
+
204
+
This method returns the configuration array for the OAuth service.
205
+
206
+
#### `getAuthURL(): string`
207
+
208
+
This method returns the authorization URL for the OAuth service.
209
+
210
+
#### `getAccessToken(string $code): string`
211
+
212
+
This method retrieves the access token for the OAuth service using the authorization code provided as a parameter.
213
+
214
+
#### `getUser(string $token): ?array`
215
+
216
+
This method retrieves the user data from the OAuth service using the access token provided as a parameter. It returns an array containing user data or `null` if the operation is unsuccessful.
217
+
218
+
155
219
## License
156
220
157
221
This library is open source and available under the [MIT License](LICENSE).
0 commit comments