Access Denied issue when connecting to XERO using oAuth2.0
I am creating an application that will allow a user to send Invoices from a local database application to XERO.
Connection works fine when running on my machine at the office but when I port it to the clients terminal server I get this error.
System.Net.HttpListenerException (0x80004005): Access is denied
at System.Net.HttpListener.AddAllPrefixes()
at System.Net.HttpListener.Start()
at XeroConnectionTest.clsXeroAuth2.VB$StateMachine_6_oauth2.MoveNext() in Q:\XeroConnectionTest\XeroConnectionTest\clsXeroAuth2.vb:line 21
This is the code where it fails
Private callbackurl As String = "http://localhost:5000/signin/"
Public Async Function oauth2() As Task(Of Boolean)
Dim redirectUri As String = String.Format(callbackurl)
Dim listener = New HttpListener()
listener.Prefixes.Add(redirectUri)
Try
listener.Start()
stopListening = False
Catch hlex As HttpListenerException
'MsgBox(hlex.ToString)
Form1.TextBox1.Text = hlex.ToString
Return False
End Try
and the error occurs on listener.start() line.
Any help would be gratefully received
Thanks
Frostie
See also questions close to this topic
-
AlphaBeta Pruning TicTacToe is not blocking, is it eval problem?
I'm debuging this for days and i don't know what I made wrong in this piece of code for Tic-Tac-Toe game and AI (well I know its not real AI but...) I have choosen for this was Alpha-Beta pruning. Its 7x7 board so it would be too heavy for pure minimax implementation.
Problem I have is that i can't figure out why Alpha-Beta is not blocking player to stall the game and wait for player move and use proper move in his favour, or just simply tie the game.
I've decided that center of board will have more points(for end score) than the one at the edges of the board. I belive that moves more to the center will have more chance to success than the ones in the edges, thats why i made AddScoreToMove function that evaluates that move. To Ensure that eval function will check EVERY possible moves at board I didn't made that function to work as find first xxx (for example at row0 and col0,col1,col2) and return (cause maybe there is 4X's or 4O's). Also 4X or 4O gives substantially more score than other ones and should be considered as win.
At this moment my PCplayer( O's) play like thisCan anyone tell me what i made wrong? It's my second program with AI, and first was with minimax on 3x3 board whitch worked fine.
C# code is below
VB.NET CODE:
Public Class Form1 Dim board As Char(,) = { {" ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " "}, {" ", " ", " ", " ", " ", " ", " "}} Class Move Public row, col As Integer End Class Dim BestMoveRow As Integer = 0 Dim BestMoveCol As Integer = 0 Dim BestMoveScore As Integer = 0 Shared player As Char = "X", opponent As Char = "O" Shared Function AddScoreToMove(thatMove As Move) As Integer Dim row As Integer = thatMove.row Dim col As Integer = thatMove.col '0 score, move is at border If ((row >= 1 And row <= 5) And col = 0) Then Return 0 ElseIf ((row >= 1 And row <= 5) And col = 6) Then Return 0 ElseIf (row = 0 And (col >= 0 And col <= 6)) Then Return 0 ElseIf (row = 6 And (col >= 0 And col <= 6)) Then Return 0 End If '1 score, thatMove is at border +1 If ((row >= 2 And row <= 4) And col = 1) Then Return 1 ElseIf ((row >= 2 And row <= 4) And col = 5) Then Return 1 ElseIf (row = 1 And (col >= 1 And col <= 5)) Then Return 1 ElseIf (row = 5 And (col >= 1 And col <= 5)) Then Return 1 End If '2 score, thatMove is at border +2 If (row = 2 And col = 2) Then Return 2 ElseIf (row = 2 And col = 4) Then Return 2 ElseIf (row = 2 And (col >= 2 And col <= 4)) Then Return 2 ElseIf (row = 4 And (col >= 2 And col <= 4)) Then Return 2 End If '3 Center thatMove If (row = 3 And col <= 3) Then Return 3 End If Return 0 'error not added lane End Function Private Shared Function eval(ByVal b As Char(,)) As Integer Dim playerScorerow As Integer = 0 Dim playerScorecol As Integer = 0 Dim playerScorecross As Integer = 0 Dim pcScorerow As Integer = 0 Dim pcScorecol As Integer = 0 Dim pcScorecross As Integer = 0 ''EVALUATE rows For row As Integer = 0 To 3 For col As Integer = 0 To 6 'initialize moves to evaluate Dim move3 As New Move With { .row = row + 3, .col = col } Dim move2 As New Move With { .row = row + 2, .col = col } Dim move1 As New Move With { .row = row + 1, .col = col } Dim move0 As New Move With { .row = row, .col = col } If Not b(row, col) = " " Then 'ITS NOT EMPTY - PLAYER OR PC MOVED HERE Dim moveScore As Integer = AddScoreToMove(move0) 'EVALUATE THAT MOVE If b(row, col) = b(row + 1, col) Then 'THERE IS 2 X or 2 O Dim move1Score As Integer = AddScoreToMove(move1) If b(row + 1, col) = b(row + 2, col) Then 'THERE IS 3x or 3O Dim move2Score As Integer = AddScoreToMove(move2) If b(row + 2, col) = b(row + 3, col) Then 'THERE IS 4X or 4O Dim move3Score As Integer = AddScoreToMove(move3) If b(row, col) = player Then 'PLAYER HAVE 4X HERE playerScorerow = Math.Max(playerScorerow, 100 + move3Score + move2Score + move1Score + moveScore) 'GET HIGHEST OF ALL EVALUATIONS OF THAT FOR LOOPS ElseIf b(row, col) = opponent Then 'PC HAVE 4O HERE pcScorerow = Math.Min(pcScorerow, -100 - move3Score - move2Score - move1Score - moveScore) End If End If If b(row, col) = player Then playerScorerow = Math.Max(playerScorerow, 5 + move2Score + move1Score + moveScore) ElseIf b(row, col) = opponent Then pcScorerow = Math.Min(pcScorerow, -5 - move2Score - move1Score - moveScore) End If End If If b(row, col) = player Then playerScorerow = Math.Max(playerScorerow, 2 + move1Score + moveScore) ElseIf b(row, col) = opponent Then pcScorerow = Math.Min(pcScorerow, -2 - move1Score - moveScore) End If End If If b(row, col) = player Then playerScorerow = Math.Max(playerScorerow, moveScore) ElseIf b(row, col) = opponent Then pcScorerow = Math.Min(pcScorerow, -moveScore) End If End If Next Next ''col win For row As Integer = 0 To 6 For col As Integer = 0 To 3 Dim move3 As New Move With { .row = row + 3, .col = col } Dim move2 As New Move With { .row = row + 2, .col = col } Dim move1 As New Move With { .row = row + 1, .col = col } Dim move0 As New Move With { .row = row, .col = col } If Not b(row, col) = " " Then Dim moveScore As Integer = AddScoreToMove(move0) If b(row, col) = b(row, col + 1) Then Dim moveScore1 As Integer = AddScoreToMove(move1) If b(row, col + 1) = b(row, col + 2) Then Dim moveScore2 As Integer = AddScoreToMove(move2) If b(row, col + 2) = b(row, col + 3) Then Dim moveScore3 As Integer = AddScoreToMove(move3) If b(row, col) = player Then playerScorerow = Math.Max(playerScorerow, 100 + moveScore3 + moveScore2 + moveScore1 + moveScore) ElseIf b(row, col) = opponent Then pcScorerow = Math.Min(pcScorerow, -100 - moveScore3 - moveScore2 - moveScore1 - moveScore) End If End If If b(row, col) = player Then playerScorerow = Math.Max(playerScorerow, 5 + moveScore2 + moveScore1 + moveScore) ElseIf b(row, col) = opponent Then pcScorerow = Math.Min(pcScorerow, -5 - moveScore2 - moveScore1 - moveScore) End If End If If b(row, col) = player Then playerScorerow = Math.Max(playerScorerow, 2 + moveScore1 + moveScore) ElseIf b(row, col) = opponent Then pcScorerow = Math.Min(pcScorerow, -2 - moveScore1 - moveScore) End If End If If b(row, col) = player Then playerScorerow = Math.Max(playerScorerow, moveScore) ElseIf b(row, col) = opponent Then pcScorerow = Math.Min(pcScorerow, -moveScore) End If End If Next Next 'NOT FULLY IMPLEMENTED 'cross win For row As Integer = 0 To 3 For col As Integer = 0 To 3 If Not b(row, col) = " " Then If (b(row, col) = b(row + 1, col + 1) AndAlso b(row + 1, col + 1) = b(row + 2, col + 2) AndAlso b(row + 2, col + 2) = b(row + 3, col + 3)) Then If b(row, col) = player Then Return +10 ElseIf b(row, col) = opponent Then Return -10 End If End If End If Next Next 'NOT FULLY IMPLEMENTED 'cross win For row As Integer = 0 To 3 For col As Integer = 3 To 6 If Not b(row, col) = " " Then If (b(row, col) = b(row + 1, col - 1) AndAlso b(row + 1, col - 1) = b(row + 2, col - 2) AndAlso b(row + 2, col - 2) = b(row + 3, col - 3)) Then If b(row, col) = player Then Return +10 ElseIf b(row, col) = opponent Then Return -10 End If End If End If Next Next Dim scoreValues() As Integer = {playerScorerow, playerScorecol, playerScorecross, pcScorerow, pcScorecol, pcScorecross} Dim max = scoreValues.OrderByDescending(Function(z) Math.Abs(z)).FirstOrDefault() Return max End Function Private Shared Function MiniMax(ByVal board As Char(,), ByVal machineMove As Boolean, ByVal depth As Integer) As Integer Const alpha As Integer = -10_000 Const beta As Integer = 10_000 Return AlphaBetaPruning(board, machineMove, depth, beta, alpha) End Function Private Shared Function AlphaBetaPruning(ByVal board As Char(,), ByVal machineMove As Boolean, ByVal depth As Integer, ByVal beta As Integer, ByVal alpha As Integer) As Integer If depth = 0 Then Return eval(board) If machineMove Then 'min PC MOVE For i As Integer = 0 To 6 For j As Integer = 0 To 6 If board(i, j) = " " Then board(i, j) = opponent Dim score As Integer = Math.Min(AlphaBetaPruning(board, Not machineMove, depth - 1, beta, alpha), eval(board)) board(i, j) = " " If score < beta Then Form1.BestMoveRow = i Form1.BestMoveCol = j Form1.BestMoveScore = score beta = score End If If alpha >= beta Then Exit For 'cutoff End If Next Next Return beta Else 'max PLAYER MOVE For i As Integer = 0 To 6 For j As Integer = 0 To 6 If board(i, j) = " " Then board(i, j) = player Dim score As Integer = Math.Max(AlphaBetaPruning(board, Not machineMove, depth - 1, beta, alpha), eval(board)) board(i, j) = " " If score > alpha Then alpha = score End If If alpha >= beta Then Exit For End If Next Next Return alpha End If End Function End Class
C# CODE
public class Form1 { private char[,] board = new[] { { " ", " ", " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " ", " ", " " } }; class Move { public int row, col; } private int BestMoveRow = 0; private int BestMoveCol = 0; private int BestMoveScore = 0; private static char player = "X"; private static char opponent = "O"; public static int AddScoreToMove(Move thatMove) { int row = thatMove.row; int col = thatMove.col; // 0 score, move is at border if (((row >= 1 & row <= 5) & col == 0)) return 0; else if (((row >= 1 & row <= 5) & col == 6)) return 0; else if ((row == 0 & (col >= 0 & col <= 6))) return 0; else if ((row == 6 & (col >= 0 & col <= 6))) return 0; // 1 score, thatMove is at border +1 if (((row >= 2 & row <= 4) & col == 1)) return 1; else if (((row >= 2 & row <= 4) & col == 5)) return 1; else if ((row == 1 & (col >= 1 & col <= 5))) return 1; else if ((row == 5 & (col >= 1 & col <= 5))) return 1; // 2 score, thatMove is at border +2 if ((row == 2 & col == 2)) return 2; else if ((row == 2 & col == 4)) return 2; else if ((row == 2 & (col >= 2 & col <= 4))) return 2; else if ((row == 4 & (col >= 2 & col <= 4))) return 2; // 3 Center thatMove if ((row == 3 & col <= 3)) return 3; return 0; // error not added lane } private static int eval(char[,] b) { int playerScorerow = 0; int playerScorecol = 0; int playerScorecross = 0; int pcScorerow = 0; int pcScorecol = 0; int pcScorecross = 0; // 'EVALUATE rows for (int row = 0; row <= 3; row++) { for (int col = 0; col <= 6; col++) { // initialize moves to evaluate Move move3 = new Move() { row = row + 3, col = col }; Move move2 = new Move() { row = row + 2, col = col }; Move move1 = new Move() { row = row + 1, col = col }; Move move0 = new Move() { row = row, col = col }; if (!b[row, col] == " ") { int moveScore = AddScoreToMove(move0); // EVALUATE THAT MOVE if (b[row, col] == b[row + 1, col]) { int move1Score = AddScoreToMove(move1); if (b[row + 1, col] == b[row + 2, col]) { int move2Score = AddScoreToMove(move2); if (b[row + 2, col] == b[row + 3, col]) { int move3Score = AddScoreToMove(move3); if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, 100 + move3Score + move2Score + move1Score + moveScore); // GET HIGHEST OF ALL EVALUATIONS OF THAT FOR LOOPS else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -100 - move3Score - move2Score - move1Score - moveScore); } if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, 5 + move2Score + move1Score + moveScore); else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -5 - move2Score - move1Score - moveScore); } if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, 2 + move1Score + moveScore); else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -2 - move1Score - moveScore); } if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, moveScore); else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -moveScore); } } } // 'col win for (int row = 0; row <= 6; row++) { for (int col = 0; col <= 3; col++) { Move move3 = new Move() { row = row + 3, col = col }; Move move2 = new Move() { row = row + 2, col = col }; Move move1 = new Move() { row = row + 1, col = col }; Move move0 = new Move() { row = row, col = col }; if (!b[row, col] == " ") { int moveScore = AddScoreToMove(move0); if (b[row, col] == b[row, col + 1]) { int moveScore1 = AddScoreToMove(move1); if (b[row, col + 1] == b[row, col + 2]) { int moveScore2 = AddScoreToMove(move2); if (b[row, col + 2] == b[row, col + 3]) { int moveScore3 = AddScoreToMove(move3); if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, 100 + moveScore3 + moveScore2 + moveScore1 + moveScore); else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -100 - moveScore3 - moveScore2 - moveScore1 - moveScore); } if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, 5 + moveScore2 + moveScore1 + moveScore); else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -5 - moveScore2 - moveScore1 - moveScore); } if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, 2 + moveScore1 + moveScore); else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -2 - moveScore1 - moveScore); } if (b[row, col] == player) playerScorerow = Math.Max(playerScorerow, moveScore); else if (b[row, col] == opponent) pcScorerow = Math.Min(pcScorerow, -moveScore); } } } // NOT FULLY IMPLEMENTED // cross win for (int row = 0; row <= 3; row++) { for (int col = 0; col <= 3; col++) { if (!b[row, col] == " ") { if ((b[row, col] == b[row + 1, col + 1] && b[row + 1, col + 1] == b[row + 2, col + 2] && b[row + 2, col + 2] == b[row + 3, col + 3])) { if (b[row, col] == player) return +10; else if (b[row, col] == opponent) return -10; } } } } // NOT FULLY IMPLEMENTED // cross win for (int row = 0; row <= 3; row++) { for (int col = 3; col <= 6; col++) { if (!b[row, col] == " ") { if ((b[row, col] == b[row + 1, col - 1] && b[row + 1, col - 1] == b[row + 2, col - 2] && b[row + 2, col - 2] == b[row + 3, col - 3])) { if (b[row, col] == player) return +10; else if (b[row, col] == opponent) return -10; } } } } int[] scoreValues = new[] { playerScorerow, playerScorecol, playerScorecross, pcScorerow, pcScorecol, pcScorecross }; var max = scoreValues.OrderByDescending(z => Math.Abs(z)).FirstOrDefault(); return max; } private static int MiniMax(char[,] board, bool machineMove, int depth) { const int alpha = -10_000; const int beta = 10_000; return AlphaBetaPruning(board, machineMove, depth, beta, alpha); } private static int AlphaBetaPruning(char[,] board, bool machineMove, int depth, int beta, int alpha) { if (depth == 0) return eval(board); if (machineMove) { for (int i = 0; i <= 6; i++) { for (int j = 0; j <= 6; j++) { if (board[i, j] == " ") { board[i, j] = opponent; int score = Math.Min(AlphaBetaPruning(board, !machineMove, depth - 1, beta, alpha), eval(board)); board[i, j] = " "; if (score < beta) { Form1.BestMoveRow = i; Form1.BestMoveCol = j; Form1.BestMoveScore = score; beta = score; } if (alpha >= beta) break; // cutoff } } } return beta; } else { for (int i = 0; i <= 6; i++) { for (int j = 0; j <= 6; j++) { if (board[i, j] == " ") { board[i, j] = player; int score = Math.Max(AlphaBetaPruning(board, !machineMove, depth - 1, beta, alpha), eval(board)); board[i, j] = " "; if (score > alpha) alpha = score; if (alpha >= beta) break; } } } return alpha; } } }
-
VB.NET - Invoke ContextMenu Item Click Programatically for WebBrowser control
I am having a WebBrowser control and loaded a local image into an IMG tag and set the DocumentText of the WebBrowser as below
<!DOCTYPE HTML> <meta http-equiv='X-UA-Compatible' content='IE=10' /> <html lang='en'> <body style='margin: 0; overflow: hidden;'> <img Width = 1269 Height = 1600 src='C:\Users\ADMIN\Desktop\p41.png'></img> </body> </html>
It is loading perfectly fine. For some reason, I want to invoke the context menu of the image and click one of the context menu items
programmatically
(say for example "Copy" - though I don't want this - I can choose any item in the menu). I don't know how to achieve this. When I tried to iterate the context menu of the browser control, I am gettingSystem.NullReferenceException: 'Object reference not set to an instance of an object.'
as I have not placed any ContextMenu control in the form, since I wanted to access the WebBrowser's inbuilt context menu. Is this achievable ?Or is there a way to get the code (which IE does) for each of its menu item, so I can directly call that - atleast for "Save picture as..." and "Copy"
Please Note: I do not want to use the "SRC" attribute to be part of any solution as I do not want that as you see I am the one forming the HTML tag with that. Hence I know that.
Please find the screenshot below
-
Math expression parsing: incorrect output when a + followed by a -
I am trying to create a program that parses an expression such as
3x^3 + 7x^2 + 6x - 9
. I am using a recursive system to do this. At the moment, I'm just testing to see if I get the correct output for the expression I input by only using constants in the expression. The code works fine with most expressions, but when I have a minus followed by a positive, both terms are subtracted (first term should be subtracted, second term should be added). An example of this is entering4*3^2-7*3+5*3
. The answer to this is 30 but the program does4*3^2-7*3-5*3
instead and outputs 0. I am unsure how to solve this.Code:
Private Function ParseExpr(ByRef expression As String) Dim op, op1 As Integer op = ParseFactor(expression) If expression.Length <> 0 Then If (expression(0) = "+") Then expression = expression.Substring(1, expression.Length - 1) op1 = ParseExpr(expression) op += op1 ElseIf (expression(0) = "-") Then expression = expression.Substring(1, expression.Length - 1) op1 = ParseExpr(expression) op -= op1 End If End If Return op End Function
-
oauth2 in core 3.1
I am using core 3.1 to connect to the canvas API, this is part of my code..
services.AddAuthentication(config => { config.DefaultAuthenticateScheme = "CanvasCookies"; config.DefaultSignInScheme = "CanvasCookies"; config.DefaultChallengeScheme = "CanvasLMS"; }) .AddCookie("CanvasCookies") .AddOAuth("CanvasLMS", config => { var canvas_domain = Configuration.GetValue<string>("Canvas:Domain"); var client_secret = Configuration.GetValue<string>("Canvas:Secret"); var client_id = Configuration.GetValue<string>("Canvas:Client_id"); config.ClientId = client_id; config.ClientSecret = client_secret; config.CallbackPath = new PathString("/oauth/callback"); //config.Scope.Add("google.com") config.AuthorizationEndpoint = $"{canvas_domain}login/oauth2/auth"; config.TokenEndpoint = $"{canvas_domain}login/oauth2/token"; config.UserInformationEndpoint = $"{canvas_domain}api/v1/users//courses"; config.SaveTokens = true; config.Events = new OAuthEvents() { OnCreatingTicket = context => { var accessToken = context.AccessToken; var base64payload = accessToken.Split('.')[1]; var bytes = Convert.FromBase64String(base64payload); var jsonPayload = Encoding.UTF8.GetString(bytes); var claims = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonPayload); foreach(var claim in claims) { context.Identity.AddClaim(new Claim(claim.Key, claim.Value)); } return Task.CompletedTask; }
this is the controller
public class APICanvasController : Controller { ... [Authorize] public async Task<IActionResult> Secret() { var serverResponse = await AccessTokenRefreshWrapper( () => SecuredGetRequest("https://localhost:44388/secret/index")); var apiResponse = await AccessTokenRefreshWrapper( () => SecuredGetRequest("https://localhost:44388/secret/index")); return View(); } private async Task<HttpResponseMessage> SecuredGetRequest(string url) { var token = await HttpContext.GetTokenAsync("access_token"); var client = _httpClientFactory.CreateClient(); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token}"); return await client.GetAsync(url); } public async Task<HttpResponseMessage> AccessTokenRefreshWrapper( Func<Task<HttpResponseMessage>> initialRequest) { var response = await initialRequest(); if (response.StatusCode == System.Net.HttpStatusCode.Unauthorized) { await RefreshAccessToken(); response = await initialRequest(); } return response; } private async Task RefreshAccessToken() { ... } } }
when I execute the code I obtain this error
Exception: The oauth state was missing or invalid. Unknown location
Exception: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler.HandleRequestAsync()
Any idea what I am doing wrong?
Thanks
-
Pass 1 parameter in oAuth to access them after redirect URI was called
I have configured a oAuth 2.0 authentication flow for my Angular singlePage website:
User opens my Login page depending on his language:
example.com/en-GB
orexample.com/de-DE
After clicking on a login Btn he get's redirected to the issuer page where he can login with his email and password.
The issuer page then redirects him to example.com/welcome
My problem is now, how to access the info about the user language once he got redirected from my welcome component. How do I know, if he came from
en-GB
odde-DE
) and if I should display the english or the german version of example.com/welcome. Can I pass the parameter in the redirect URI, I tried but it didn't work?I also tried taking the queryParam from the route in my login Component in step 1 and then put the value into a
Service
. That's usually how I pass data between components. But after the redirect, when the welcome component gets opened, the value is always null. I tried doing it with BehaviorSubject with a starting value of null.Then I tried passing the value into my authConfig by using
customQueryParams
orcustomTokenParameters
, but I don't know how to access these params from my welcome component once the redirect happend. They are not included in the identityClaims that I receive after the redirect.:let authConfig: AuthConfig = { issuer: 'myIssuer.com', redirectUri: 'example.com/welcome', clientId: ..., scope: '...', responseType: '...', customQueryParams: { 'locale': 'de_DE' }, customTokenParameters: ["de-DE"], dummyClientSecret: ... };
Does anyone know the correct way to do this?
-
How do I use access tokens without refresh tokens and a third party?
I am working on a progressive web app (and single page app). Currently users always have to login and will be kicked out after session timeout. So now I managed to generate an access token on the server and give it to the user through an http only cookie. When the user request a resource from the server, its checked if the user is logged in and if not, the user gets logged in if he has a valid token. The problem now is, that I have heard of refresh tokens, but I also read that you dont have to use them anymore. (https://stackoverflow.com/questions/57650692/where-to-store-the-refresh-token-on-the-client#:~:text=5%20Answers&text=You%20can%20store%20encrypted%20tokens%20securely%20in%20HttpOnly%20cookies.&text=If%20you%20worry%20about%20long,not%20use%20it%20at%20all.) Also there are references to OAuth 2.0. But what has OAuth to do with my problem? Isn't OAuth for third party authentication only? I really dont know how to solve this problem (expiring access tokens) now.
Thank you in advance for any kind of help
-
Xero API Forbidden getting Item
This only happened in the past few days that I am having this issue but only for getting an Item. I can get contacts and get branding themes. Therefore, tenand id is working and accesstoken.
This is the endpoint when i'm getting item:
https://api.xero.com/api.xro/2.0/Items/SHO B 100 S
Response:
{ "Type": null, "Title": "Forbidden", "Status": 403, "Detail": "AuthenticationUnsuccessful", "Instance": "94aa22f4-6ba1-43f6-8f76-699befb1b1f3", "Extensions": {} }
And this is the scope:
offline_access accounting.transactions openid profile email accounting.contacts accounting.settings
I am not sure what had changed but everything is working except getting an item. Please tell me how can I fix this and what causes the issue. Thank you so much in advance.
-
Xero API - list all groups shown on Profit & Loss Report
We are using the Xero API to track expenses and show them via the associated "Groups" listed in the Profit and Loss report.
In the Demo Company, there are a bunch of these groups - eg. Advertising, Bank Fees, Commission, General Expenses, Entertainment etc
Is there a way to retrieve the full list of "groups" associated with a Xero accounts Profit and Loss report?
We have been doing this by retrieving the Profit and Loss report directly and pulling the group data out of it - but as there is a 365 day limitation, we are only able to retrieve the Groups that appear within that 365 day span.
Is there a way to retrieve all groups for the entire history of the users Xero account?
-
Xero (Accounting) job number retrieval from Invoices
I'm new to Xero and not sure how I can get the job number out of invoice details. All the invoices are associated with a Job Number in our system. Unfortunately, I'm not seeing the job number as a separate field but as a part of the description. See screenshot below.
I'm using Xero .net SDK to get data from Xero and I was able to get Contacts, Invoices, and Purchase orders but now I need to get the Job number out of Invoices. How we can achieve this?
When I query a single invoice using invoice id I get line items in a list but that is also not having that description that has the job number so that I can extract that from the description. I may be wrong Please correct me what is the correct approach to get the Job Number.
Here is the login URL with scopes I use to get the code to get the access token
https://login.xero.com/identity/connect/authorize?response_type=code&client_id=4F6E00D21C2A4575877A34C37AA0000D&redirect_uri=https://localhost:5050&scope=openid profile email files accounting.transactions accounting.transactions.read accounting.reports.read accounting.journals.read accounting.settings accounting.settings.read accounting.contacts accounting.contacts.read accounting.attachments accounting.attachments.read offline_access payroll.employees payroll.payruns payroll.payslip payroll.settings payroll.timesheets assets&state=123&code_challenge=H6E6d30D7iYVRdVu3twjE5lX2APLAf1E2z4FO$AQZNU&code_challenge_method=S256