Skip to content

Commit

Permalink
feat(authentication-service): Added Instagram oauth2 (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankrathi0403 authored May 11, 2021
1 parent a02b792 commit 5567fe9
Show file tree
Hide file tree
Showing 15 changed files with 658 additions and 5 deletions.
5 changes: 5 additions & 0 deletions services/authentication-service/.env.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ GOOGLE_AUTH_CLIENT_ID=a
GOOGLE_AUTH_CLIENT_SECRET=q
GOOGLE_AUTH_TOKEN_URL=q
GOOGLE_AUTH_CALLBACK_URL=q
INSTAGRAM_AUTH_URL=q
INSTAGRAM_AUTH_CLIENT_ID=a
INSTAGRAM_AUTH_CLIENT_SECRET=q
INSTAGRAM_AUTH_TOKEN_URL=q
INSTAGRAM_AUTH_CALLBACK_URL=q
REDIS_PORT=a
REDIS_HOST=a
REDIS_URL=
Expand Down
5 changes: 5 additions & 0 deletions services/authentication-service/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ GOOGLE_AUTH_CLIENT_ID=
GOOGLE_AUTH_CLIENT_SECRET=
GOOGLE_AUTH_TOKEN_URL=
GOOGLE_AUTH_CALLBACK_URL=
INSTAGRAM_AUTH_URL=
INSTAGRAM_AUTH_CLIENT_ID=
INSTAGRAM_AUTH_CLIENT_SECRET=
INSTAGRAM_AUTH_TOKEN_URL=
INSTAGRAM_AUTH_CALLBACK_URL=
FORGOT_PASSWORD_LINK_EXPIRY=
KEYCLOAK_HOST=
KEYCLOAK_REALM=
Expand Down
346 changes: 346 additions & 0 deletions services/authentication-service/OPEN_API_SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,352 @@ func main() {
This operation does not require authentication
</aside>

## LoginController.loginViaInstagram

<a id="opIdLoginController.loginViaInstagram"></a>

> Code samples
```shell
# You can also use wget
curl -X GET /auth/instagram \
-H 'Accept: application/json'

```

```http
GET /auth/instagram HTTP/1.1
Accept: application/json
```

```javascript

const headers = {
'Accept':'application/json'
};

fetch('/auth/instagram',
{
method: 'GET',

headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

```

```ruby
require 'rest-client'
require 'json'

headers = {
'Accept' => 'application/json'
}

result = RestClient.get '/auth/instagram',
params: {
}, headers: headers

p JSON.parse(result)

```

```python
import requests
headers = {
'Accept': 'application/json'
}

r = requests.get('/auth/instagram', headers = headers)

print(r.json())

```

```php
<?php

require 'vendor/autoload.php';

$headers = array(
'Accept' => 'application/json',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('GET','/auth/instagram', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...

```

```java
URL obj = new URL("/auth/instagram");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());

```

```go
package main

import (
"bytes"
"net/http"
)

func main() {

headers := map[string][]string{
"Accept": []string{"application/json"},
}

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "/auth/instagram", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

```

`GET /auth/instagram`

<h3 id="logincontroller.loginviainstagram-parameters">Parameters</h3>

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|client_id|query|string|false|none|
|client_secret|query|string|false|none|

> Example responses
> 200 Response
```json
{
"accessToken": "string",
"refreshToken": "string",
"expires": 0,
"pubnubToken": "string"
}
```

<h3 id="logincontroller.loginviainstagram-responses">Responses</h3>

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Instagram Token Response|[TokenResponse](#schematokenresponse)|

<aside class="success">
This operation does not require authentication
</aside>

## LoginController.instagramCallback

<a id="opIdLoginController.instagramCallback"></a>

> Code samples
```shell
# You can also use wget
curl -X GET /auth/instagram-auth-redirect \
-H 'Accept: application/json'

```

```http
GET /auth/instagram-auth-redirect HTTP/1.1
Accept: application/json
```

```javascript

const headers = {
'Accept':'application/json'
};

fetch('/auth/instagram-auth-redirect',
{
method: 'GET',

headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});

```

```ruby
require 'rest-client'
require 'json'

headers = {
'Accept' => 'application/json'
}

result = RestClient.get '/auth/instagram-auth-redirect',
params: {
}, headers: headers

p JSON.parse(result)

```

```python
import requests
headers = {
'Accept': 'application/json'
}

r = requests.get('/auth/instagram-auth-redirect', headers = headers)

print(r.json())

```

```php
<?php

require 'vendor/autoload.php';

$headers = array(
'Accept' => 'application/json',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array();

try {
$response = $client->request('GET','/auth/instagram-auth-redirect', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}

// ...

```

```java
URL obj = new URL("/auth/instagram-auth-redirect");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());

```

```go
package main

import (
"bytes"
"net/http"
)

func main() {

headers := map[string][]string{
"Accept": []string{"application/json"},
}

data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "/auth/instagram-auth-redirect", data)
req.Header = headers

client := &http.Client{}
resp, err := client.Do(req)
// ...
}

```

`GET /auth/instagram-auth-redirect`

<h3 id="logincontroller.instagramcallback-parameters">Parameters</h3>

|Name|In|Type|Required|Description|
|---|---|---|---|---|
|code|query|string|false|none|
|state|query|string|false|none|

> Example responses
> 200 Response
```json
{
"accessToken": "string",
"refreshToken": "string",
"expires": 0,
"pubnubToken": "string"
}
```

<h3 id="logincontroller.instagramcallback-responses">Responses</h3>

|Status|Meaning|Description|Schema|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Instagram Redirect Token Response|[TokenResponse](#schematokenresponse)|

<aside class="success">
This operation does not require authentication
</aside>

## LoginController.loginViaKeycloak

<a id="opIdLoginController.loginViaKeycloak"></a>
Expand Down
Loading

0 comments on commit 5567fe9

Please sign in to comment.