Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add external api #54

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add external api #54

wants to merge 4 commits into from

Conversation

Allen-Cherian
Copy link
Contributor

No description provided.

'peerId': peerId,
'orgName': orgName,
});
var response = await http.post(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might need a try catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http post can fail too, we need catch for that case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

}

class OrgAccessToken {
static final int _accessTokenMaxAge = 30; // days
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token age might be something we have to worry about but not during a poc. We need to come back on this.

@@ -25,4 +28,26 @@ Future<Response> handleTransactionRequest(Request request) async {
return Response.ok('Transaction request received');
}

Future<bool> externalApi({required String did,required String peerId,required String orgName,required String callBackUrl,required Token orgAccessToken })async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be named fireAuthCallback or something similar. It
doesn't need orgName
did and peerId need not be separate

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will make these changes and put a new commit.

@vyshnavsdeepak
Copy link
Contributor

Also generate protos again to fix the conflicts, I had merged a pending PR to avoid confusion

@@ -25,4 +28,26 @@ Future<Response> handleTransactionRequest(Request request) async {
return Response.ok('Transaction request received');
}

Future<bool> externalApi({required String did,required String peerId,required String orgName,required String callBackUrl,required Token orgAccessToken })async {
var bodyJsonStr = jsonEncode({
'did': did,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

session id too

Uri.http(callBackUrl),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'Authorization': 'Bearer $orgAccessToken',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

token should move to body. We are giving a token for them to access our apis

Future<bool> externalApi({required String did,required String peerId,required String orgName,required String callBackUrl,required Token orgAccessToken })async {
var bodyJsonStr = jsonEncode({
'did': did,
'peerId': peerId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add chain too. also add chain in access token

@@ -25,4 +28,26 @@ Future<Response> handleTransactionRequest(Request request) async {
return Response.ok('Transaction request received');
}

Future<bool> externalApi({required String did,required String peerId,required String orgName,required String callBackUrl,required Token orgAccessToken })async {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at the last, this function shall move to another file as it is generic. Shall create a new module, - sky_outgoing_calls

return false;
}
}catch(e){
print(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print stack trace too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

});
try{
var response = await http.post(
Uri.http(callBackUrl),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Uri.parse

var bodyJsonStr = jsonEncode({
'did': '$did.$peerId',
'session_id': sessionId,
'token': orgAccessToken,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orgAccessToken is of Token class, we just need the token value inside it which is a string, that is what we can pass through an api.

Future<OrgStatus> approveOrgAuthRequest(
ServiceCall call, OrgAuthRequest request) async {
var user = RubixService.getAuthUser(call);
const rubix = 'rubix';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must have been coming from phone,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, no, not need as this is rubix ext rpc. But could have simply passed this to the next function without having to store it in a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok will make that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants