FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
parse-server/src/authDataManager/github.js at master · LukeJenx/parse-server · GitHub
LukeJenx
/
parse-server
Public
forked from
parse-community/parse-server
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
parse-server
/
src
/
authDataManager
/
github.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (47 loc) · 1.31 KB
Breadcrumbs
parse-server
/
src
/
authDataManager
/
github.js
Copy path
File metadata and controls
51 lines (47 loc) · 1.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Helper functions for accessing the github API.
var
https
=
require
(
'https'
)
;
var
Parse
=
require
(
'parse/node'
)
.
Parse
;
// Returns a promise that fulfills iff this user id is valid.
function
validateAuthData
(
authData
)
{
return
request
(
'user'
,
authData
.
access_token
)
.
then
(
(
data
)
=>
{
if
(
data
&&
data
.
id
==
authData
.
id
)
{
return
;
}
throw
new
Parse
.
Error
(
Parse
.
Error
.
OBJECT_NOT_FOUND
,
'Github auth is invalid for this user.'
)
;
}
)
;
}
// Returns a promise that fulfills iff this app id is valid.
function
validateAppId
(
)
{
return
Promise
.
resolve
(
)
;
}
// A promisey wrapper for api requests
function
request
(
path
,
access_token
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
https
.
get
(
{
host
:
'api.github.com'
,
path
:
'/'
+
path
,
headers
:
{
'Authorization'
:
'bearer '
+
access_token
,
'User-Agent'
:
'parse-server'
}
}
,
function
(
res
)
{
var
data
=
''
;
res
.
on
(
'data'
,
function
(
chunk
)
{
data
+=
chunk
;
}
)
;
res
.
on
(
'end'
,
function
(
)
{
data
=
JSON
.
parse
(
data
)
;
resolve
(
data
)
;
}
)
;
}
)
.
on
(
'error'
,
function
(
e
)
{
reject
(
'Failed to validate this access token with Github.'
)
;
}
)
;
}
)
;
}
module
.
exports
=
{
validateAppId
:
validateAppId
,
validateAuthData
:
validateAuthData
}
;
Back
|
FazBrowse Home
|
New Git URL