Skip to content

Commit

Permalink
Added PAT option
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar committed Apr 15, 2024
1 parent 1c0e266 commit 48a4666
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
19 changes: 15 additions & 4 deletions M.pq
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ let
GitHubUser = "OscarValerock",
GitHubRepo = "PowerQueryFunctions",
BaseURL = "https://api.github.com/repos/",
PAT = "", // Personal Access Token (PAT) for GitHub API https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
QueryHeaders = if PAT <> ""
then
[Authorization = "Bearer " & PAT]
else
[],

#"Get Trees all trees" = Json.Document(
Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/trees/main",
Query = []
Query = [],
Headers = QueryHeaders
]
)
),
Expand All @@ -21,7 +28,8 @@ let
Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/trees/"&filterList,
Query = []
Query = [],
Headers = QueryHeaders
]
)
),
Expand All @@ -32,7 +40,8 @@ let
Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/trees/"& tree,
Query = []
Query = [],
Headers = QueryHeaders
]
)
)[tree],
Expand All @@ -52,7 +61,8 @@ let
#"Get functions fx" = Json.Document(Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/blobs/"&relativePath,
Query = []
Query = [],
Headers = QueryHeaders
]
))[content],
#"To text" =
Expand Down Expand Up @@ -164,6 +174,7 @@ let
Type.Is = Type.Is,
Value.ReplaceType = Value.ReplaceType,
Value.Type = Value.Type
//,Web.Contents = Web.Contents //Unfortunately adding this function to the M code will create a dynamic error :(
]
)
in
Expand Down
23 changes: 18 additions & 5 deletions M_Creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
'www.linkedin',
'youtu.be',
]
manual_strings = [ ]
manual_strings = [
'Number.Abs'
]

M_Code = """
Expand All @@ -38,12 +40,19 @@
GitHubUser = "OscarValerock",
GitHubRepo = "PowerQueryFunctions",
BaseURL = "https://api.github.com/repos/",
PAT = "", // Personal Access Token (PAT) for GitHub API https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens
QueryHeaders = if PAT <> ""
then
[Authorization = "Bearer " & PAT]
else
[],
#"Get Trees all trees" = Json.Document(
Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/trees/main",
Query = []
Query = [],
Headers = QueryHeaders
]
)
),
Expand All @@ -54,7 +63,8 @@
Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/trees/"&filterList,
Query = []
Query = [],
Headers = QueryHeaders
]
)
),
Expand All @@ -65,7 +75,8 @@
Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/trees/"& tree,
Query = []
Query = [],
Headers = QueryHeaders
]
)
)[tree],
Expand All @@ -85,7 +96,8 @@
#"Get functions fx" = Json.Document(Web.Contents(
BaseURL,[
RelativePath = GitHubUser&"/"&GitHubRepo&"/git/blobs/"&relativePath,
Query = []
Query = [],
Headers = QueryHeaders
]
))[content],
#"To text" =
Expand All @@ -95,6 +107,7 @@
),
[
#TextToReplace
//,Web.Contents = Web.Contents //Unfortunately adding this function to the M code will create a dynamic error :(
]
)
in
Expand Down

0 comments on commit 48a4666

Please sign in to comment.